Skip to main content

Basic Nginx Configuration

This guide covers only the most important Nginx configuration steps for Debian/Ubuntu and CentOS systems.


1. Main Config File

  • Main Config: /etc/nginx/nginx.conf
  • Sites Directory: /etc/nginx/sites-available/ and /etc/nginx/sites-enabled/

2. Change Default Web Root (Optional)

Edit the default site configuration:

sudo nano /etc/nginx/sites-available/default

Look for root directive and change the path as needed.

3. Test Configuration

sudo nginx -t

4. Reload/Restart Nginx

sudo systemctl reload nginx
# or
sudo systemctl restart nginx

Tip: After changes, always test config and reload Nginx.