Nginx is a powerful server application that routes network traffic. It’s often used as a reverse proxy server but can also be configured as a web server. Therefore there are a few important Nginx commands you should be aware of in order to get familiar with the basics of this web server. These commands are essential when applying new changes or when troubleshooting issues.
Nginx Commands
Reference the following list of popular commands if you ever need a quick reminder on how to use a certain command or what it does.
Status Nginx
You can display the status of the Nginx service by entering the following command in a terminal
sudo systemctl status nginx
Start Nginx
sudo systemctl start nginx
sudo /etc/init.d/nginx start
Stop Nginx
Stopping Nginx will kill all system processes quickly. This will terminate Nginx even if there are open connections.
sudo systemctl stop nginx
sudo /etc/init.d/nginx stop
Restart Nginx
Use one of the following commands to run an Nginx restart
sudo systemctl restart nginx
sudo /etc/init.d/nginx restart
Quit Nginx
sudo systemctl quit nginx
Reload Nginx
You can reload Nginx by using one of the following commands
sudo systemctl reload nginx
sudo /etc/init.d/nginx reload
Test Nginx Configuration
This helps prevent any unforeseen errors which can cause your website to gown down.
nginx -t
Check Nginx Version
systemctl -v nginx