This is a small post on how to start troubleshooting Nginx server. If you are facing an issue with nginx or any server/service the first thing to conform is if our configurations are correct or not. Nginx have two commands to show if there is any issue with your configuration or not.
Checking your configs with service command
service nginx configtest
For a failed test you will get below output:
root@linuxnix:/etc/nginx# service nginx configtest
* Testing nginx configuration [fail]
If you observe the above command, it is giving some hint about configuration error but it is not giving more information what error it is.
Test your configurations with nginx command to get more information about what error you have in your configuraton.
-t is for testing your configuraton
root@linuxnix:/etc/nginx# nginx -t
nginx: [emerg] unexpected "}" in /etc/nginx/sites-enabled/www.linuxnix.com:37
nginx: configuration file /etc/nginx/nginx.conf test failed
From the above message we can see there is an error in 37 line.
If you don't find any issue with your nginx config then our next stop is at logs which are important source of information on what is happening with that server. By default nginx logs are located in /var/log/nginx, but if they are not located there don’t be panic. We have to check nginx configuration file /etc/nginx/nginx.conf for exact log file location. To know your log file entries just search for below words in /etc/nginx/nginx.conf file.
access_log or error_log
Once you are able to find logs from there we can see what happening at server and take nessary stops to make our nginx server working.
Want to check configurations settings for other service then have a look at our post on "Linux/Unix:Server configuration file syntax Checking commands"
Latest posts by Surendra Anne (see all)
- Online training on Linux Bash shell scripting - February 8, 2018
- 15 iostat command examples in Linux/Unix - December 4, 2017
- How to Installing and Configuring Firewalld on Linux - November 29, 2017
- 4 sleep command examples in Linux/Unix - November 2, 2017
- 5 SSH alias examples in Linux - October 16, 2017