使用脚本将nginx1.9.12升级到nginx1.17.3的简单记录

nginx各个版本的下载链接

http://nginx.org/download/

旧的版本及编译的选项:

[root@v73 nginx-1.9.12]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.9.12
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module

 

升级脚本:

#!/bin/bash
cd $2 && cd sbin                                  #向脚本提供的第二个参数为NGINX的安装目录,例如/usr/local/nginx/
./nginx -V &>nginxmakeinfos.txt         
cnfg=`cat nginxmakeinfos.txt | awk 'END {print}' | awk -F ":" '{print $2}'`   #利用前面打印的结果获取安装的选项
tar -zxvf $1 -C /tmp/
basenames=`basename $1`
ngdir=`echo ${basenames%%.tar.gz*}`
cd /tmp/$ngdir
./configure$cnfg                                                                  #按照旧版本的安装选项进行下一步的编译
make
cp -r $2 /tmp/ngbak`date +%Y%m%d%H%M%S`             #备份
cd $2 && mv sbin/nginx sbin/nginx.old
cp /tmp/$ngdir/objs/nginx sbin/                                         #拷贝二进制文件
cd /tmp/$ngdir
make upgrade                                                                   #升级
cd $2/sbin
./nginx -V

 

升级效果:

[root@v73 linuxapp]# sh -x upnginx2.sh /shared/app/install/tar.gz/nginx-1.17.3.tar.gz /usr/local/nginx/

 

 

 

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页