Linux 更新 Nginx

nginx-1.22.0.tar.gz下载地址

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. 检查升级是否成功,如接口是否访问正常

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值