nginx编译安装后怎么对nginx进行平滑升级
一、nginx新版的下载
下载页面:
wget -c http://nginx.org/download/nginx-1.13.12.tar.gz
二、获取老版本nginx的配置
查看当前版本: /usr/local/nginx/sbin/nginx -v
查看当前配置: /usr/local/nginx/sbin/nginx -v
[root@zixuephp nginx-1.13.6]# /usr/local/nginx/sbin/nginx -v nginx version: nginx/1.13.6 [root@zixuephp nginx-1.13.6]# /usr/local/nginx/sbin/nginx -v nginx version: nginx/1.13.6 built by gcc 4.8.5 20150623 (red hat 4.8.5-16) (gcc) built with openssl 1.0.2k-fips 26 jan 2017 tls sni support enabled configure arguments: --prefix=/usr/local/nginx --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-pcre --with-http_ssl_module
三、解压新版nginx源码包
tar -xzvf nginx-1.13.12.tar.gz cd nginx-1.13.12
四、对新版重新编译前的配置
这里的配置和老版本的一样 : /usr/local/nginx/sbin/nginx -v
复制代码 代码如下:
./configure --prefix=/usr/local/nginx --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-pcre --with-http_ssl_module
五、编译生成objs目录,进入目录,替换nginx
make
编译后通过ls可以看到有个objs的目录
[root@zixuephp nginx-1.13.12]# ls auto changes changes.ru conf configure contrib html license makefile man objs readme src [root@zixuephp nginx-1.13.12]#
进入objs目录,替换老版本的nginx主程序(在操作这里前一定要先备份,免得出错)
[root@zixuephp objs]#mv nginx /usr/local/nginx/sbin/nginx
六、平滑升级
make upgrade
七、升级成功,查看版本
[root@zixuephp nginx-1.13.12]# /usr/local/nginx/sbin/nginx -v nginx version: nginx/1.13.12 [root@zixuephp nginx-1.13.12]# /usr/local/nginx/sbin/nginx -v nginx version: nginx/1.13.12 built by gcc 4.8.5 20150623 (red hat 4.8.5-16) (gcc) built with openssl 1.0.2k-fips 26 jan 2017 tls sni support enabled configure arguments: --prefix=/usr/local/nginx --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-pcre --with-http_ssl_module
在升级前一定要提前备份好nginx程序和网站等文件,避免出错。