T4 — Instalação do Nginx
✅ Pré-requisitos
Wiki topics:
🔓 · Open Source
T4 — Instalação do Nginx Pré-requisitos
- Tens NGINX instalado? Se não:
sudo dnf install nginx -y

- Inicia e ativa o serviço:
sudo systemctl start nginx
sudo systemctl enable nginx

1. Cria as pastas para os sites
sudo mkdir -p /var/www/a.ipg.pt/html
sudo mkdir -p /var/www/b.ipg.pt/html
sudo mkdir -p /var/www/c.ipg.pt/html

Define permissões:
sudo chown -R $USER:$USER /var/www

2. Cria ficheiros index.html simples
echo "<h1>Site A</h1>" > /var/www/a.ipg.pt/html/index.html
echo "<h1>Site B</h1>" > /var/www/b.ipg.pt/html/index.html
echo "<h1>Site C</h1>" > /var/www/c.ipg.pt/html/index.html

3. Cria os server blocks (virtual hosts)
Cria estes ficheiros de config:
/etc/nginx/conf.d/a.ipg.pt.conf
server {
listen 80;
server_name a.ipg.pt;
root /var/www/a.ipg.pt/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}

/etc/nginx/conf.d/b.ipg.pt.conf
server {
listen 80;
server_name b.ipg.pt;
root /var/www/b.ipg.pt/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
/etc/nginx/conf.d/c.ipg.pt.conf

server {
listen 80;
server_name c.ipg.pt;root /var/www/c.ipg.pt/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}

4. Verifica e reinicia NGINX
sudo nginx -t
sudo systemctl reload nginx

5. Testar localmente (sem DNS real)
Edita o ficheiro hosts local:
sudo nano /etc/hosts
Adiciona:
127.0.0.1 a.ipg.pt
127.0.0.1 b.ipg.pt
127.0.0.1 c.ipg.pt

Depois abre no browser:



made with love by Rodrigo Henriques
메타데이터
- post_id
- 91de5fae4dcb
- slug
- t4-instalação-do-nginx-91de5fae4dcb
- url
- https://medium.com/@rodrigomatiashenriques/t4-instala%C3%A7%C3%A3o-do-nginx-91de5fae4dcb
- canonical_url
- https://medium.com/@rodrigomatiashenriques/t4-instala%C3%A7%C3%A3o-do-nginx-91de5fae4dcb
- author_url
- https://medium.com/@rodrigomatiashenriques
- status
- ok
- fetched_at
- 2026-06-20 20:29:01