Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Common operations for rookie beginners to use Nginx foundation

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Nginx start, restart, close command stop operation

All processes that require ps's current Nginx before stopping the operation

Step 1: query the nginx main process number

Ps-ef | grep nginx

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

Step 2: send a signal to stop Nginx calmly:

Kill-QUIT main process number Quick stop Nginx:kill-TERM main process number force stop Nginx:pkill-9 nginx

In addition, if the pid file storage path is configured in nginx.conf, the file is stored in the Nginx main process number, if not specified, it is placed in the logs directory of nginx. With the pid document, instead of querying the main process number of Nginx, we send a signal directly to Nginx with the following command:

Kill-signal type'/ usr/nginx/logs/nginx.pid' smooth restart

If you change the configuration, you have to restart Nginx. Do you want to close Nginx and then turn it on? No, you can send a signal to Nginx and restart smoothly.

Smooth restart command: kill-HUP resides in the name or process number file path

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, so as to avoid errors in Nginx that affect the stable operation of the server after restart.

The command to determine whether the Nginx configuration is correct is as follows:

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

Or

/ usr/nginx/sbin/nginx-t smooth upgrade

If the running Nginx of the server wants to upgrade, add or delete modules, we need to stop the server and make corresponding modifications, so that the server will stop service within a period of time, and Nginx can carry out various upgrade actions without affecting the server operation.

Step 1: if you upgrade the Nginx program, first replace the old program file with the new program. If you compile and install the new program, the new program will be compiled directly into the Nginx installation directory.

Step 2: execute the Linux command https://www.linuxcool.com/

The main process number or process file name of the kill-USR2 legacy program

At this point, the old Nginx main process will rename its process file to .oldbin, and then execute the new version of Nginx. The new and old Nginx will run with the city to process the request together.

To phase out the old version of Nginx, enter the command:

Kill-WINCH old version main process number

Slowly, the old work process will exit with the completion of the task, and the work process of the new version of Nginx will gradually replace the old one. At this point, we can decide whether to use the new version or revert to the old version.

Do not reload configuration start new / old worker process kill-HUP old / new version main process number calmly close old / new process kill-QUIT old / new main process number

If an error is reported at this time, indicating that there is still a process that is not finished, use the following command to close the old / new worker process first, and then close the main process number:

Turn off the main process number kill-TERM old / new worker process number

In this way, if you want to restore to the old version, all you need to do is to operate the new version of the main process number, and if you want to use the new version, the above steps will operate the old version of the main process number.

Related command / usr/local/nginx-1.0.6/sbin/nginx / / start nginx/usr/local/nginx-1.0.6/sbin/nginx-t / / Test the accuracy of the nginx configuration file / usr/local/nginx-1.0.6/sbin/nginx-s reload / / reload nginx/usr/local/nginx-1.0.6/sbin/nginx-s stop / / disable nginx/usr/local/nginx-1.0.6/sbin/ Nginx- V / / View nginx installed modules / usr/local/nginx-1.0.6/sbin/nginx-v / / View nginx version / usr/local/nginx/sbin/nginx-s reload / / reload nginx

Address: https://www.linuxprobe.com/nginx-status-reload.html

Editor: Wu Xiangping, auditor: Yi Zengbao

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report