How to smoothly upgrade nginx after compiling and installing nginx

How to smoothly upgrade nginx after compiling and installing nginx

After nginx is compiled and installed and used for a period of time, if you find that the current version has vulnerabilities or needs new functions, you need to upgrade the current nginx version, but it should not affect normal use. Therefore, you need to smoothly upgrade nginx and update it to the latest version.

This article demonstrates the process of upgrading nginx-1.13.6 to nginx-1.13.12, which is also applicable to other versions.

1. Download the new version of nginx

Download page: http://nginx.org/en/download.html

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

2. Get the configuration of the old version of nginx

Check 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 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 the code 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, and replace nginx

make

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

[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 mistakes)

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

6. Smooth upgrade

make upgrade

7. Upgrade successfully, 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

Before upgrading, be sure to back up the nginx program, website and other files in advance to avoid errors.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of the process of smooth upgrade of nginx
  • Nginx 1.8.0 version smoothly upgraded to the new version 1.9.7
  • Detailed operation method of Nginx smooth upgrade

<<:  Solution to the problem "Table mysql.plugin doesn't exist" when deploying MySQL

>>:  How to elegantly implement the mobile login and registration module in vue3

Recommend

Vue realizes the card flip effect

This article example shares the specific code of ...

HTML table tag tutorial (3): width and height attributes WIDTH, HEIGHT

By default, the width and height of the table are...

Linux uses if to determine whether a directory exists.

How to use if in Linux to determine whether a dir...

How to install ionCube extension using pagoda

1. First install the pagoda Installation requirem...

Practical record of solving MySQL deep paging problem

Table of contents Preface Why does limit deep pag...

Several solutions for forgetting the MySQL password

Solution 1 Completely uninstall and delete all da...

How to mount a new disk on a Linux cloud server

background A new server was added in the company,...

js to realize login and registration functions

This article example shares the specific code of ...

Detailed explanation of HTML's <input> tag and how to disable it

Definition and Usage The <input> tag is use...

Implementation of two basic images for Docker deployment of Go

1. golang:latest base image mkdir gotest touch ma...

How to set up ssh password-free login to Linux server

Every time you log in to the test server, you alw...

mysql row column conversion sample code

1. Demand We have three tables. We need to classi...