1. As for upgrading and installing nginx third-party modules, you need to check the version of nginx installed and the compiled parameters.
[root@ittestserver1 opt]# /usr/local/nginx2/sbin/nginx -V nginx version: nginx/1.10.3 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) built with OpenSSL 1.1.0e 16 Feb 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx2 --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_stub_status_module --with-http_v2_module --with-openssl=/tmp/install/openssl-1.1.0e --with-http_v2_module #Pay attention to configure arguments. When upgrading, keep consistent!
2. Download the nginx version to be upgraded
No more details about this. You can use wget or go to the official website to compress packets, and then upload them via ftp. Download address: http://nginx.org/cn/download.html
3. Unzip the ningx installation package and perform the configure operation (the parameters are the same as those found in step 1).
[root@ittestserver1 soft]# tar xf nginx-1.12.1.tar.gz [root@ittestserver1 soft]# cd nginx-1.12.1 [root@ittestserver1 nginx-1.12.1]# ls auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src [root@ittestserver1 nginx-1.12.1]# ./configure --prefix=/usr/local/nginx2 \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-http_realip_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-http_stub_status_module \ --with-http_v2_module \ --with-openssl=/tmp/install/openssl-1.1.0e \ --with-http_v2_module
PS: if the server does not install the software dependent on nginx, such as openssl, prce, etc., and it is not the root user, and cannot use yum for installation, you can use parameters to specify the corresponding dependent source path (you need to download the dependent source code yourself), for example, specify the prce dependency: -- with PCRE = [prce source code]
4. Execute make, remember not make install
[root@ittestserver1 soft]# make
5. Back up the old nginx file and copy the new nginx file
[root@ittestserver1 nginx-1.12.1]# mv /usr/local/nginx2/sbin/nginx /usr/local/nginx2/sbin/nginx.bak [root@ittestserver1 nginx-1.12.1]# cp objs/nginx /usr/local/nginx2/sbin/
6. Replace the old nginx process with make upgrade (smooth upgrade)
[root@ittestserver1 nginx-1.12.1]# make upgrade #Note that this is done in the directory where make is performed.
7. Execute / usr/local/nginx2/sbin/nginx -V to view the latest version and compiled parameters of nginx
[root@ittestserver1 nginx-1.12.1]# /usr/local/nginx2/sbin/nginx -V nginx version: nginx/1.12.1 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) built with OpenSSL 1.1.0e 16 Feb 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx2 --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_stub_status_module --with-http_v2_module --with-openssl=/tmp/install/openssl-1.1.0e --with-http_v2_module
Reference resources: https://blog.51cto.com/liqingbiao/1948430