nginx平滑升级

要求:升级nginx版本到1.21.6

1.查看nginx和OpenSSL版本,记录原安装编译的模块:

[root@host sbin]# ./nginx -V
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=--prefix=/data/service/nginx --with-http_ssl_module --with-stream

2.备份原 nginx 二进制文件,切换到nginx所在目录进行备份,备份的过程系统不受影响,

防止误操作建议备份整个nginx安装文件夹

cp -r /data/service/nginx/sbin/nginx  /data/service/nginx/sbin/nginx_$(date +%F)
cp -r /data/service/nginx /data/service/nginx_$(date +%F)

3.升级,此时不要执行 make install,要不然就会覆盖原来的版本产生诸多问题。

wget http://nginx.org/download/nginx-1.21.6.tar.gz
tar -xvf nginx-1.21.6.tar.gz
cd nginx-1.21.6
 ./configure  --prefix=/data/service/nginx --with-http_ssl_module --with-stream
make

4.复制nginx-1.21.6下的nginx到原来的nginx目录下,注意nginx-1.21.6中nginx在objs目录下而不是在sbin下面

[root@host nginx-1.21.6]# cd objs/
[root@host objs]# cp nginx /data/service/nginx/sbin/

测试是否替换成功

[root@host sbin]# /data/service/nginx/sbin/nginx -t
nginx: the configuration file /data/service/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@host sbin]# /data/service/nginx/sbin/nginx -V
nginx version: nginx/1.21.6
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled

 

 

你可能感兴趣的:(nginx,运维,https)