Nginx Commands Cheat Sheet

Techie     January 2023

Introduction

The following are usefull commands for nginx on linux.


Part A: Commands

1 . Check nginx version

$ nginx -v


2 . Start nginx server

$ sudo service nginx start


3 . Stop nginx server

$ sudo service nginx stop


4 . Restart nginx server

$ sudo service nginx restart


5 . Reload nginx server

$ sudo service nginx reload


6 . Check nginx status

$ sudo service nginx status


7 . Find syntax errors in the Nginx configuration file after making changes

$ sudo nginx -t

# or

$ sudo nginx -t -c /path/to/the/file


Part B: File locations

1 . Log Files

/var/log/nginx/access.log
/var/log/nginx/error.log


2 . Global config file

/etc/nginx/conf.d/mod-http-passenger.conf


3 . Default server file /etc/nginx/sites-enabled/default


That’s it! Thanks for reading, see you in the next one!