Where is the Nginx Config File Located?

The Nginx configuration file can be in multiple locations and can also include several other config files.

To edit the nginx configuration file, first try here.

sudo nano /etc/nginx/nginx.conf

nginx.conf may also include some other config files, for example:

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

If you followed one of our guides for setting up multiple domains for Nginx, the config may be located here (where example.com is your own domain)

sudo nano /etc/nginx/sites-enabled/example.com

If you can’t find Nginx config in the above location, try one of these:

sudo nano /usr/local/nginx/conf/nginx.conf
sudo nano /usr/local/etc/nginx/nginx.conf

If you still can’t find it, try locate.

locate nginx.conf

To save file and exit in nano, press CTRL + X, press Y and then press ENTER)

To check that the Nginx config file is valid after saving.

sudo nginx -t

If valid, reload Nginx service.

sudo service nginx reload

Let me know in the comments if this helped. Follow me @DevAnswers or buy me a beer 🍺

Feedback

Your email address will not be published. Required fields are marked *

We use Markdown to style comments, like on Github and Reddit.
To do a line break, type two spaces after the sentence.
You can add inline code by wrapping it in backticks: `code here`

    To do an entire block of code  
    type four spaces before the line
    and it will appear in a block like this.
    <-- four empty spaces