1. 显示老版本和配置选项信息 /usr/local/nginx/sbin/nginx -V
[root@BlueTV-YuShengChan-CMSZhuanJiDIY nginx]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.0.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_stub_status_module --with-http_realip_module --with-http_sub_module --with-pcre --with-http_ssl_module --with-http_gzip_static_module --with-file-aio --with-stream
2.开始之前先确认原来的服务可以正常访问,比如接口访问正常。便于校验更新是否成功
3.停止Nginx服务
/usr/local/nginx/sbin/nginx -s stop
4.解压
cd /usr/local
tar -zxvf nginx-1.22.0.tar.gz
cd nginx-1.22.0
5.执行./configure
根据第一步中的配置选项信息执行 ./configure
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_stub_status_module --with-http_realip_module --with-http_sub_module --with-pcre --with-http_ssl_module --with-http_gzip_static_module --with-file-aio --with-stream
6. 编译
make && make insatll
7. 打包原配置文件夹
cd /usr/local/nginx
tar -czvf conf.tar.gz /usr/local/nginx-bak/conf
8. 删除 老版本的 conf 替换为 新版本的 conf
cp /usr/local/nginx-bak/conf.tar.gz
cp /usr/local/nginx-bak/conf.tar.gz /usr/local/nginx
rm -rf /usr/local/nginx/config
解压
cd /usr/local/nginx
tar -zxvf conf.tar.gz
9. 设置配置文件(默认是:/etc/nginx/nginx.conf)并启动 Nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
10. 显示老版本和配置选项信息 /usr/local/nginx/sbin/nginx -V
[root@BlueTV-YuShengChan-CMSZhuanJiDIY nginx]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.22.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_stub_status_module --with-http_realip_module --with-http_sub_module --with-pcre --with-http_ssl_module --with-http_gzip_static_module --with-file-aio --with-stream
11. 检查升级是否成功,如接口是否访问正常