• 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 Use sed to Find and Replace String in Files

    How to Use sed to Find and Replace String in Files

    December 18, 2020
  • Linux Head Command

    Linux Head Command

    December 16, 2020
  • Rename Files and Directories in Linux

    How to Rename Files and Directories in Linux

    December 15, 2020

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS 8
    How to Install Python 3.9 on CentOS 8 December 31, 2020
  • How to Install Php 8 on Debian 10
    How to Install PHP 8 on Debian 10 January 2, 2021
  • How to Install Php 8 on Ubuntu 20.04
    How to Install PHP 8 on Ubuntu 20.04 December 28, 2020
  • How to Install GIMP on Debian 10
    How to Install GIMP 2.10 on Debian 10 December 27, 2020
  • How to Install GIMP 2.10 on CentOS 8
    How to Install GIMP 2.10 on CentOS 8 December 30, 2020
© 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