Introduction
Nginx, which sounds like “engine x,” is an outstanding performance HTTP primarily reverse proxy server that is free, open-source, and currently in charge of managing the load on most of the busiest websites on the Internet. This can be utilized as an independent web server or it can serve as a reverse proxy for Apache along with other web servers.
Most likely, whether you work as a programmer or system administrator, you deal with Nginx routinely. The most frequently performed tasks while working with an Nginx web server are starting, halting, and then restarting/reloading.
The process to Start, Stop, and Restart Nginx in Linux servers is covered in this tutorial.
System Requirements
You’ll require
- a machine with Nginx configure and set up
- the ability to use a terminal window and command line
- an individual account with root or sudo rights
- If the scenario that you’re working remotely, an active SSH connection to a distant system
Start Stop and Restart Nginx in Linux using systemctl
The most recent versions of Ubuntu 18.04/16.04, CentOS 7/8, & Debian 10/9 use SystemD as their system and service manager.
Restarting or reloading the web server processes is necessary each time you make adjustments to the start Nginx configuration. The Nginx service has to get restarted. Run the following command:
sudo systemctl restart nginx
If possible, reload rather than restart when modifying or adding server blocks. Whenever you make significant changes, such as switching ports or interfaces, you should restart the nginx service. When a page gets reloaded, Nginx loads the updated configuration, launches fresh worker processes using the updated configuration, and gently terminates older worker processes.
To relaunch your Nginx service, execute the command below:
sudo systemctl restart nginx
Additionally, signals may get utilized to directly regulate Nginx. For instance, you might execute the following command for reloading the service:
sudo /usr/sbin/nginx -s reload
Execute the following command to launch the start Nginx service.
sudo systemctl start nginx
To terminate the Nginx service, enter the following command:
sudo systemctl stop nginx
Start Stop and Restart Nginx using Command Line
Your Nginx command provides the ability to use the set of integrated management tools that Nginx provides for the service.
Start with Nginx
Type the following to launch Nginx and its associated processes:
sudo /etc/init.d/nginx start
The terminal window display is going to display the following when the operation was successful:
The output
- [ ok ] Starting nginx (via systemctl): nginx.service.
Restarting Nginx
To forcefully stop and resume Nginx and associated processes:
sudo /etc/init.d/nginx restart
On the other hand, employ this nginx -s command:
sudo nginx -s restart nginx
Stop NGINX
Use the following commands to halt or deactivate the Nginx service:
sudo /etc/init.d/nginx stop
You may also use:
sudo nginx -s stop
Reloading Nginx
Nginx and its associated processes can be properly stopped and restarted by using nginx the following command:
sudo /etc/init.d/nginx reload
If you’d rather give Nginx commands right away, you can do so by using the nginx -s command:
sudo nginx -s reload
Nginx Quit
Force Utilise the quit command along with the nginx -s command to stop the Nginx service:
sudo nginx -s quit
Start, Stop and Reload Nginx using SysVinit
An Nginx service gets started, stopped, and restarted utilizing init.d scripts in previous (EOLed) editions of Ubuntu, and CentOS, including Debian.
Restarting Nginx is necessary:
sudo service nginx restart
Activate the Nginx services:
sudo service nginx start
Suspend the Nginx services:
sudo service nginx stop
Summing Up
In this article, I have explained how starting, stopping, and restarting Nginx in Linux on the server got covered in this post. If you’re administering an Nginx web server, you can use the aforementioned commands for the tasks that come up most often.