Home >Operation and Maintenance >Nginx >How to achieve smooth restart and upgrade of nginx

How to achieve smooth restart and upgrade of nginx

WBOY
WBOYforward
2023-05-21 17:07:06994browse

If you change the nginx configuration file (nginx.conf) and want to restart nginx, you can also do it by sending a system signal to the nginx main process. However, before restarting, make sure the syntax of the nginx configuration file (nginx.conf) is correct, otherwise nginx will not load the new configuration file. You can determine whether the nginx configuration file is correct by using 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 which line of the configuration file is wrong:

[emerg]:unknowndirective"abc"inlusrllocauwebserverlnginxjconflnginx.conf:55
configurationfile/usr/local/webserver/ nginx/conf/nginx·conf test failed

If the configuration file is correct, the screen will prompt 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 time, nginx can be restarted smoothly.

Copy code The code is as follows:

/usr/local/www/nginx/sbin/nginx -xs reloadx

or:

Copy code The code is as follows:

killx -hup `cat /usr/local/www/nginx/logs/nginx.pidx`

The following 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 compilation parameters

./configure --prefix=/usr/local/www/nginx --with-pcre=/yujialin/pcre-8.12 --with-http_stub_status_module --with-http_gzip_static_module
Use the above paragraph to compile

Then make, don’t make install

After making, there will be an extra 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 Execute upgrade

After 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

The above is the detailed content of How to achieve smooth restart and upgrade of nginx. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete