Centos 6.9下nginx 1.12.1平滑升级1.14.2
1、查看当前Nginx版本
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.12.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.1.0f 25 May 2017
TLS SNI support enabled
configure arguments: --with-http_gunzip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-openssl=/opt/software/openssl-1.1.0f
[root@localhost sbin]#
查看nginx版本的时候,configure后面有一大串模块,这是安装nginx时所指定的模块,升级的时候也要指定,并可以添加其他模块。
2、安装nginx
下载openssl和nginx
[root@localhost local]# wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz
[root@localhost local]# tar xzvf openssl-1.1.1b.tar.gz
[root@localhost local]# wget http://nginx.org/download/nginx-1.14.2.tar.gz
[root@localhost local]# tar xzvf nginx-1.14.2.tar.gz
[root@localhost local]# cd nginx-1.14.2
编译、安装
[root@localhost nginx-1.14.2]# ./configure --with-http_gunzip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-openssl=/usr/local/openssl-1.1.1b
[root@localhost local]#make
make完以后,不需要执行make install,否则会覆盖安装,nginx服务有问题。
先重命名原nginx二进制文件,然后拷贝新编译生成的nginx文件到安装目录
[root@localhost sbin]# mv nginx nginx-1.13.5
[root@localhost nginx-1.14.2]# cp objs/nginx /opt/nginx/sbin/
执行升级命令
[root@localhost nginx-1.14.2]# make upgrade
/opt/nginx/sbin/nginx -t
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
kill -USR2 `cat /opt/nginx/logs/nginx.pid`
sleep 1
test -f /opt/nginx/logs/nginx.pid.oldbin
kill -QUIT `cat /opt/nginx/logs/nginx.pid.oldbin`
[root@localhost nginx-1.14.2]#
验证版本
进入安装目录,查看nginx版本
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.14.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.1.1b 26 Feb 2019
TLS SNI support enabled
configure arguments: --with-http_gunzip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-openssl=/usr/local/openssl-1.1.1b
已经完成平滑升级。
3、补充说明
平滑升级,从1.12到1.13,从1.13到1.14,或者直接从1.12到1.14都验证可行。但是还是建议升级之前备份原nginx目录。