• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Start, Stop, or Restart Nginx

Written by Admin, Updated On October 16, 2020
nginx, terminal
How to Start, Stop, or Restart Nginx

Nginx is a free, high performance and open-source HTTP and reverse proxy server. It can be used as a standalone web server, and as a reverse proxy for Apache and other web servers. In this guide, we will show you how to start, stop and restart Nginx on Linux.

For a system administrator or a developer, starting, stopping, and restarting are the most common tasks when working with an Nginx webserver.

Prerequisites#

You should logged in as root or user account with sudo privileges.

Currently, most of Linux distributions are using SystemD as the default init system and service manager. Below are the arguments to manage the Nginx service:

  • start: It will start the Nginx service.
  • stop: Used to terminate the Nginx service.
  • restart: To stop and then start the Nginx service again.
  • reload: Gracefully restarts the Nginx service. On reload, the main Nginx process shuts down the child processes, loads the new configuration, and starts new child processes.
  • status: Shows the service status.

For all the Linux distributions, commands for managing the Nginx service are the same.

Start, Stop and Restart Nginx using systemctl#

All the latest linux distributions like, Ubuntu 20.04 / 18.04, Debian 10 / 9, CentOS 8, 7 releases have the SystemD as a default system and service manager.

It’s required to restart or reload the nginx service whenever you made any changes to Nginx configuration. To restart the Nginx service use the following command:

sudo systemctl restart nginx

It recommended that you reload Nginx service when you add or edit server blocks. On reload the Nginx loads the new configuration and starts the processes with the new configuration. While the restart only making significant changes like changing ports or interfaces.

To reload the Nginx service run the below command:

sudo systemctl restart nginx

You can directly controlled the Nginx using signals. For instance, to reload the service you can use the following command:

sudo /usr/sbin/nginx -s reload

Start the Nginx service by running the following command:

sudo systemctl start nginx

Execute the following command to stop the Nginx service:

sudo systemctl stop nginx

Conclusion#

You have learned how to start, stop, and restart the Nginx web server on Linux systems.

If you have any questions or feedback, feel free to comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article Du Command in Linux
Next Article   Get and Change the Current Working Directory in Python

Related Posts

  • How to Install WordPress with Nginx on Debian 11

    How to Install WordPress with Nginx on Debian 11

    March 22, 2023
  • How to Install LEMP Stack on Ubuntu 22.04

    How to Install LEMP Stack on Ubuntu 22.04

    March 18, 2023
  • How to Install Set Up Nginx Server Blocks on Ubuntu 22.04

    How to Set Up Nginx Server Blocks on Ubuntu 22.04

    March 4, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook