Restart Nginx in Ubuntu

The nginx web server can be restarted using any one of the following command line syntax. Use systemctl on systemd based version such as Ubuntu Linux 16.04LTS and above:

sudo systemctl restart nginx

OR

sudo service nginx restart

OR (older Ubuntu Linux version):

sudo /etc/init.d/nginx restart

The same commands can be used to start / stop / restart the nginx server on a Red Hat 7 versions:

sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx

OR

sudo service nginx start
sudo service nginx stop
sudo service nginx restart

OR

sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx restart

To view status of your nginx server, use any one of the following command:

sudo service nginx status

OR

sudo /etc/init.d/nginx status

OR for Red Hat 7, CentOS 7 and higher

sudo systemctl status nginx

File probably is there: /usr/local/nginx/sbin/nginx to be sure You can do:

ps aux | grep nginx

To kill process:

sudo killall nginx

And start again:

/usr/local/nginx/sbin/nginx