English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

In-depth Explanation of Nginx start, restart, and shutdown commands in Linux

Start operation

nginx -c /usr/local/nginx/conf/nginx.conf 

-The c parameter specifies the path to the nginx configuration file to be loaded

Stop operation

The operation of stopping is carried out by sending a signal to the nginx process

Step1: query Nginx main process number

ps -ef | grep nginx

Find the master process in the process list, and its number is the main process number.

 

Step2: send signal

Gracefully stop Nginx:

kill -QUIT main process number 

For example: kill -QUIT 16391

Quickly stop Nginx:

kill -TERM main process number 

Force stop Nginx:

kill -9 Main process number 

 In addition, if the path of the pid file is configured in nginx.conf, the file stored is the main process number of Nginx. If not specified, it is placed in the Nginx logs directory. With the pid file, we don't have to query the main process number of Nginx first, but can send a signal directly to Nginx, the command is as follows:

kill -signal type/usr/local/nginx/logs/nginx.pid

Smooth restart

If you change the configuration, you need to restart Nginx, should you close Nginx first and then open it? No, you can send a signal to Nginx to restart smoothly.

Smooth restart command:

kill -HUP to the path of the title or process number file 

or use

/usr/nginx/sbin/nginx -s reload 

Note that after modifying the configuration file, it is best to check whether the modified configuration file is correct to avoid errors in Nginx after restart affecting the stable operation of the server. The command to check if the Nginx configuration is correct is as follows:

nginx -t -c /usr/nginx/conf/nginx.conf 

or

/usr/nginx/sbin/nginx -t 

That's all for this article. Hope it helps with your learning and that you will support the Yell Tutorial more.

Statement: The content of this article is from the network, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume any relevant legal liability. If you find any content suspected of copyright infringement, please send an email to notice#w3Please report any violations by sending an email to codebox.com (replace # with @ when sending an email), and provide relevant evidence. Once verified, this site will immediately delete the infringing content.

You May Also Like