Nginx start, restart, and close the command

Source: Internet
Author: User
Tags nginx server
Start, restart, and stop nginx by sending a signal to the nginx process (see the linux article). Step 1: query the nginx main process number ps-ef | grepnginx find the master process in the process list, and its number is the master... start, restart, and stop nginx by sending a signal to the nginx process (see the linux chapter). Step 1: query the nginx master process number ps-ef | grep nginx in the process list to find the master process. its number is the master process number. Step 2: send a signal to stop Nginx: kill-QUIT master process number quickly stop Nginx: kill-TERM Master process number forcibly stop Nginx: pkill-9 nginx. if the pid file storage path is configured in conf, the file stores the Nginx main process number. If no pid file is specified, the file is stored in the nginx logs directory. With the pid file, we do not need to first query the main process Number of Nginx, but directly send a signal to Nginx. the command is as follows: kill-signal type '/usr/nginx/logs/nginx. pid 'smooth restart: If the configuration is changed, restart Nginx. do you need to disable Nginx before enabling it? No. you can send a signal to Nginx to restart Nginx smoothly. Smooth restart command: use kill-HUP to enter the file path of the title or process number, or use/usr/nginx/sbin/nginx-s reload. note, after modifying the configuration file, you 'd better check whether the modified configuration file is correct to avoid Nginx errors affecting the stable running of the server. 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: if the running Nginx server needs to be upgraded, added, or deleted, we need to stop the server and modify it accordingly, in this way, the server will stop service for a period of time. Nginx can perform various upgrades without affecting the server operation without stopping services. Step 1: If the Nginx program is upgraded, replace the old program file with the new program, and compile and install the new program directly into the Nginx installation directory. Step 2: execute the command kill-USR2 master process number or process file name of the old version of the program. at this time, the old Nginx master process will rename its own process file. and then execute the new Nginx version. The old and new Nginx servers run in the same city to process requests. In this case, you need to gradually stop the old version of Nginx, and enter the command: kill-WINCH old version master process number. the old working process will exit as the task is executed, the working processes of the new Nginx version will gradually replace the old ones. At this time, we can decide whether to use the new version or restore to the old version. Do not reload the configuration to start the new/old worker process kill-HUP old/new master process number to easily close the old/new process kill-QUIT old/new master process number. If an error is reported at this time, if there is still a process that is not terminated, run the following command to first close the old/new working process, and then close the master process number: kill-TERM old/new working process number, to recover to the old version, you only need to perform operations on the master process number in the previous steps. if you want to use the new version, you can perform operations on the master process number in the previous steps. The above are some basic operations of Nginx. I hope Nginx can have a better way to handle these operations in the future. it is best to use Nginx commands instead of sending system signals to the Nginx process.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.