ArticleDirectory
- What is a PID file?
- Nginx default PID File
- Modify the PID in the configuration file
- Stop nginx with PID File
- Reload the configuration file with the PID File
The following command is generally used to restart nginx:
Kill-Quit 26000
In this example, 26000 is the main process Number of nginx.
Every time, you need to run the ps command to query the main process Number of nginx, which is very troublesome. In the book "Practical nginx: replacing Apache with a high-performance WEB server", we mentioned the method of using the PID file. Unfortunately, something is missing from the command. Here we provide the complete command.
What is a PID file?
The PID file is a plain text file that records the PID of the process.
The following is the content of a PID file ::
26032
Nginx default PID File
Nginx uses the PID file to record the PID of the master process. If it is not specified during compilation, its path is:
<Prefix>/logs/nginx. PID
<Prefix> is the installation path of nginx.
If you want to modify the default PID file path, you can add the configuration during compilation. The parameters are as follows ::
./Configure -- PID-Path =/data/test/ngx. PID
After it is specified, the default PID file path is changed ::
/Data/test/ngx. PID
If only the path is specified and no PID file name is specified, the PID file name is still nginx. PID.
Modify the PID in the configuration file
In addition to the default value and the modification during compilation, you can also modify it in the nginx configuration file. As follows:
Pid/data/test/nginx. PID;
The modified value is only valid for nginx that uses the configuration file.
Stop nginx with PID File
Assume that the PID file path is/data/logs/nginx. PID.
Kill-Quit 'cat/data/logs/nginx. Pi'
Reload the configuration file with the PID File
Kill-HUP 'cat/data/logs/nginx. Pi'