Home >Operation and Maintenance >Nginx >How to smoothly upgrade nginx after nginx is compiled and installed

How to smoothly upgrade nginx after nginx is compiled and installed

王林
王林forward
2023-05-13 20:25:111377browse

1. Download the new version of nginx

How to smoothly upgrade nginx after nginx is compiled and installed

Download page:

wget -c http://nginx.org/download/nginx-1.13.12.tar.gz

2. Get the old version of nginx Configuration

View the current version: /usr/local/nginx/sbin/nginx -v

View the current configuration: /usr/local/ nginx/sbin/nginx -v

[root@zixuephp nginx-1.13.6]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.13.6
[root@zixuephp nginx-1.13.6]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.13.6
built by gcc 4.8.5 20150623 (red hat 4.8.5-16) (gcc) 
built with openssl 1.0.2k-fips 26 jan 2017
tls sni support enabled
configure arguments: --prefix=/usr/local/nginx --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-pcre --with-http_ssl_module

3. Unzip the new version of nginx source code package

tar -xzvf nginx-1.13.12.tar.gz
cd nginx-1.13.12

4. Configuration before recompiling the new version

The configuration here is the same as the old version: /usr/local/nginx/sbin/nginx -v

Copy code The code is as follows:

./configure - -prefix=/usr/local/nginx --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module - -with-pcre --with-http_ssl_module

5. Compile and generate the objs directory, enter the directory, replace nginx

make

After compilation, you can see that there is an objs through ls directory

[root@zixuephp nginx-1.13.12]# ls
auto changes changes.ru conf configure contrib html license makefile man objs readme src
[root@zixuephp nginx-1.13.12]#

Enter the objs directory and replace the old version of the nginx main program (be sure to back up before operating here to avoid errors)

[root@zixuephp objs]#mv nginx /usr/local/nginx/sbin/nginx

6. Smooth upgrade

make upgrade

7. The upgrade is successful, check the version

[root@zixuephp nginx-1.13.12]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.13.12
[root@zixuephp nginx-1.13.12]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.13.12
built by gcc 4.8.5 20150623 (red hat 4.8.5-16) (gcc) 
built with openssl 1.0.2k-fips 26 jan 2017
tls sni support enabled
configure arguments: --prefix=/usr/local/nginx --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-pcre --with-http_ssl_module

Be sure to back up the nginx program and website files in advance before upgrading to avoid errors.

The above is the detailed content of How to smoothly upgrade nginx after nginx is compiled and installed. 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