How to achieve smooth restart and upgrade of nginx

WBOY
Release: 2023-05-21 17:07:06
forward
990 people have browsed it

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template