start stop restart nginx server

Start / Restart / Stop Nginx Web Server on Ubuntu

How do I restart/stop / start the Nginx web server under a Ubuntu Linux operating system using the command line option?

Also read: Configure Nginx Server + Reverse Proxy + Nodejs App + PM2 process manager + Google Cloud + Debian

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

Also read: How to Install Apache Groovy on Ubuntu 20.04 / 18.04

Restart nginx on Ubuntu

Type the following command:

sudo systemctl restart nginx

OR

sudo service nginx restart

OR (older Ubuntu Linux version):

sudo /etc/init.d/nginx restart

Start / Stop Nginx Commands

The same commands can be used to start / stop / restart the nginx server on a Ubuntu Linux. For example:

sudo systemctl start nginx 
sudo systemctl stop nginx 

One can use the following service command to restart or start or stop Nginx web server on an older version of Ubuntu server:

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

To view status of your Nginx server

Use any one of the following command:

sudo service status nginx

OR

sudo systemctl status nginx
? nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2016-11-02 22:17:38 UTC; 2 days ago
  Process: 303 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0
  Process: 264 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited,
 Main PID: 304 (nginx)
   CGroup: /system.slice/nginx.service
           ??304 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
           ??305 nginx: worker process                           
           ??306 nginx: worker process                           
           ??307 nginx: worker process                           
           ??308 nginx: worker process                           
           ??309 nginx: worker process                           
           ??310 nginx: worker process                           
           ??311 nginx: cache manager process                    

Nov 02 22:17:38 newcbz systemd[1]: Starting A high performance web server and a reverse proxy se
Nov 02 22:17:38 newcbz systemd[1]: Started A high performance web server and a reverse proxy ser

A note about reload nginx server

It is also possible to use the following syntax to reload nginx server after you made changes to the config file such as nginx.conf:

sudo nginx -s reload

OR

sudo systemctl reload nginx

OR

sudo service nginx reload

It is also possible to use the systemd systemctl and journalctl commands for details on errors:

$ sudo systemctl status nginx.service

$ sudo journalctl -xe

Conclusion

You learned how to restart, start, stop the Nginx web server on Ubuntu Linux using command-line options. See nginx home page here for more info.

https://www.techbiriyani.com/how-to-install-the-openlitespeed-web-server-on-ubuntu-18-04-20-04/

Leave a Reply

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