Site icon DesignLinux

How to Start, Stop, or Restart Nginx

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:

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.

Exit mobile version