Smooth change of nginx configuration without stopping Nginx service
1. After modifying the/usr/local/webserver/nginx/conf/nginx.conf configuration file, execute the following command to check if the configuration file is correct:
/usr/local/webserver/nginx/sbin/nginx-t
If the screen displays the following two lines of information, the configuration file is correct:
The configuration file/usr/local/webserver/nginx/conf/nginx.conf syntax is OK
The configuration file/usr/local/webserver/nginx/conf/nginx.conf was tested successfully
2. Smooth restart:
①, for Nginx 0.8.x version, now smooth restart Nginx configuration is very simple, execute the following command:
/usr/local/webserver/nginx/sbin/nginx-s Reload
②, for the previous version of Nginx 0.8.x, smooth restart a little more trouble, follow the steps below. Enter the following command to view the Nginx main process number:
Ps-ef | grep "Nginx:master Process" | Grep-v "grep" | Awk-f ' {print $} '
The screen displays the Nginx main process number, for example:
6302
At this point, execute the following command to make the modified Nginx configuration file effective:
Kill-hup 6302
Or do not need to be so troublesome to find the Nginx PID file:
Kill-hup ' Cat/usr/local/webserver/nginx/nginx.pid '
(go) Smooth change nginx configuration without stopping Nginx service