The following main summary of the basic operation of Nginx.
Start Action Command:
Nginx-c/usr/nginx/conf/nginx.conf
The-c parameter specifies the Nginx configuration file path to load.
Stop operation The stop operation is done by sending a signal to the nginx process (what is a signal refer to a Linux article)
Step 1: Query Nginx main process number
Ps-ef | grep nginx
In the process list, look for the master process, which is numbered as the main process number.
Step 2: Send a signal
calmly stop nginx: Kill-quit Main process Number
Quick Stop Nginx: Kill-term Main process Number
Force stop Nginx: Pkill-9 Nginx
In addition, if the nginx.conf configured PID file storage path, the file is stored in the Nginx main process number, if not specified then placed in the Nginx logs directory. With the PID file, we do not need to first query the main process number of the nginx, but directly to the nginx send a signal, the command is as follows:
Kill-Signal type '/usr/nginx/logs/nginx.pid '
Smooth reboot
If you change the configuration, restart the Nginx, turn off Nginx before you open it? No, you can send a signal to the nginx, smooth reboot.
Smooth Restart command:
Kill-hup live in the title or process number file path
Note that after modifying the configuration file, it is best to check that the modified profile is correct so that the Nginx error affects the stable operation of the server after the reboot. Determine if the Nginx configuration is correctly ordered as follows:
Nginx-t-c/usr/nginx/conf/nginx.conf
Smooth upgrade
If the server is running Nginx to upgrade, add or remove modules, we need to stop the server and make the appropriate changes, so that the server will be stopped for a period of time, Nginx can be non-stop in the case of a variety of upgrade actions without affecting the server running.
Step 1:
If you upgrade the Nginx program, replace the old program files with a new program, and compile the installation, the new program is compiled directly into the Nginx installation directory.
Step 2: Execute the command
KILL-USR2 The main process number or process file name of the legacy program
At this point the old Nginx main process will rename its process file to. oldbin, and then execute the new nginx. The old and new Nginx conjunction with City run together to handle the request.
To gradually stop the old version of Nginx, enter the command:
Kill-winch Old Moderator Process number
The slowly old work process will exit as the task executes, and the new Nginx work process gradually replaces the old version of the work process.
At this point, we can decide to use the new version or revert to the old version.
To start a new/old worker process without overloading the configuration
Kill-hup old/New main process number
Calmly close the old/new process
Kill-quit old/New main process number
If you have an error at this point, you are prompted to close the old/new worker process with the following command, and then close the main process number:
Kill-term old/New worker process number
In this way, if you want to revert to the old version, only a few of the above steps are to operate the new main process number, if you want to use the new version of the above several steps to operate the old moderator process number on the line.
The above is nginx some basic operations, hope that Nginx can have a better way to handle these operations, preferably nginx command rather than send the system signal to Nginx process.
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.