Basic Nginx Configuration
This guide covers only the most important Nginx configuration steps for Debian/Ubuntu and CentOS systems.
1. Main Config File
- Debian/Ubuntu
- CentOS
- Main Config:
/etc/nginx/nginx.conf - Sites Directory:
/etc/nginx/sites-available/and/etc/nginx/sites-enabled/
- Main Config:
/etc/nginx/nginx.conf - Sites Directory:
/etc/nginx/conf.d/
2. Change Default Web Root (Optional)
- Debian/Ubuntu
- CentOS
Edit the default site configuration:
sudo nano /etc/nginx/sites-available/default
Look for root directive and change the path as needed.
Edit the default site configuration:
sudo nano /etc/nginx/conf.d/default.conf
Look for root directive and change the path as needed.
3. Test Configuration
- Debian/Ubuntu
- CentOS
sudo nginx -t
sudo nginx -t
4. Reload/Restart Nginx
- Debian/Ubuntu
- CentOS
sudo systemctl reload nginx
# or
sudo systemctl restart nginx
sudo systemctl reload nginx
# or
sudo systemctl restart nginx
Tip: After changes, always test config and reload Nginx.