How to Start, Stop, or Restart Nginx?Share Tweet Share Pin it
Nginx is a very efficient and most famous web server application. Due to its high performance and low stress on hardware resources almost all the developers or hosting companies use it.
If you are one of them who are not familiar with CLI (Command Line Interface) and don’t know how to start, stop, or restart the Nginx in order to manage the web services. Learn here now.
Before You Begin
Instructions shown here assumes that you’ve logged in as root or root privileged user. If not, then better switch to a root user.
Nginx service uses the following arguments:
status– Know the status of the Nginx service.
start– Start the Nginx service.
stop– Stop the Nginx service.
restart– Restart the Nginx service (forceful).
reload– Restart the Nginx service (graceful).
Learn to Start, Stop and Restart the Nginx Service
If you don’t know whether the Nginx is running or not, then you can execute the following command to know the status.
systemctl status nginx
Nginx service can be started by executing the following command.
systemctl start nginx
If you want to stop the Nginx service for any reason use…
systemctl stop nginx
Nginx needs a restart when there is a config change in HTTP, Server, or any other block where there is a change. So, you can restart the nginx by executing the following command.
systemctl restart nginx
The above restart command is a hard way to restart the service, it can disrupt the web services or cause downtime for a few moments if there is a real-world load on the server.
So in this situation reload is the best option. Reload is graceful, it will create a new child and dump all the load there and closes the old child. To gracefully reload execute the following command.
systemctl reload nginx
This is how the Nginx service can be managed.