nginx smooth restart and upgrade implementation method
- 2020-05-06 12:16:57
- OfStack
If you change the Nginx configuration file (nginx.conf) and want to restart Nginx, you can also do this by sending the system signal to the Nginx main process. However, before you restart, make sure that the syntax of the Nginx configuration file (nginx.conf) is correct, or Nginx will not load the new configuration file. To determine if the Nginx configuration file is correct, use the following command:
/usr/local/webserver/nginx/sbin/nginx -t -c
/usr/local/webserver/nginx/conf/nginx.conf
If the configuration file is incorrect, the screen will prompt the wrong line of the configuration file:
[emerg]:unknowndirective"abc"inlusrllocaUwebserverlnginxjconflnginx.conf:55
Configurationfile/usr/local/webserver/nginx/conf/nginx ・ conf test failed
If the configuration file is correct, the screen prompts the following two lines of information:
The configuration file/usr/loca/webserver/nginx/conf/nginx.conf syntax is ok
Configuration file/usr/local/webserver/nginx/conf/nginx.conf test is successful
At this point, you can restart the Nginx smoothly.
/usr/local/www/nginx/sbin/nginx -xs reloadx
Or:
killx -HUP `cat /usr/local/www/nginx/logs/nginx.pidx`
here are some additions:
Smooth restart kill - HUP ` cat usr/local/www/nginx/logs/nginx pid `
smooth upgrade nginx
cd /yujialin
wget http://nginx.org/download/nginx-1.0.6.tar.gz
tar zxvf nginx-1.0.6.tar.gz
cd nginx-1.0.6
/usr/local/www/nginx/sbin/nginx -V
nginx: nginx version: nginx/1.0.4
nginx: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)
nginx: configure arguments: --prefix=/usr/local/www/nginx --with-pcre=/yujialin/pcre-8.12 --with-http_stub_status_module --with-http_gzip_static_module
This step is to get the build parameter
./configure --prefix=/usr/local/www/nginx --with-pcre=/yujialin/pcre-8.12 --with-http_stub_status_module --with-http_gzip_static_module
Compile
Then make, never make install
make, nginx in the objs directory, this is the new version of the program
mv /usr/local/www/nginx/sbin/nginx /usr/local/www/nginx/sbin/nginx-20110906
cp objs/nginx /usr/local/www/nginx/sbin/nginx
/usr/local/www/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successfu
make upgrade performs an upgrade to
After the execution/usr/local/nginx/sbin/nginx - V
nginx: nginx version: nginx/1.0.6
nginx: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)
nginx: configure arguments: --prefix=/usr/local/www/nginx --with-pcre=/yujialin/pcre-8.12 --with-http_stub_status_module --with-http_gzip_static_module