一般我们在使用nginx中,部署安装一个版本,但是由于业务需要进行nginx版本升级,这个时候,我们想不卸载原有的配置,通过最小化改变来完成nginx升级。
咱们演示下 nginx1.6.3平滑升级到 nginx1.10.3【不影响原有的配置文件】
首先下载nginx安装包:
[root@localhost ~]# wget http://nginx.org/download/nginx-1.10.3.tar.gz
解压压缩包:
[root@localhost ~]#tar xf nginx-1.10.3.tar.gz
编译安装:
[root@localhost ~]#cd nginx-1.10.3/
[root@localhost ~]#./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --http-log-path=/var/log/nginx/access.log --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-http_realip_module
[root@localhost ~]#make
注意:
此时不要执行 make install,要不然就会覆盖原来的版本产生诸多问题。
复制启动文件:
[root@localhost ~]# cp /root/nginx-1.10.3/objs/nginx /usr/local/nginx/sbin/
平滑升级:
[root@localhost nginx-1.10.3]# make upgrade
查看版本:
[root@localhost nginx-1.10.3]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.10.3
到这里就升级成功啦。