Nginx升级

下载新版本的nginx软件,nginx-1.22.0.tar.gz
查看nginx和OpenSSL版本,


[root@host sbin]cd /usr/local/nginx/sbin
[root@host sbin]# ./nginx -V
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (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_v2_module

备份原 nginx 二进制文件,切换到nginx所在目录进行备份,备份的过程系统不受影响

cp nginx nginx-1.18

将压缩包上传到服务器进行解压,上传任意位置,没有要求

tar xf nginx-1.20.1.tar.gz 

切换到解压后的nginx文件夹内执行,只需要到 make,千万不要 make install 。如果make install 会将原来的配置文件覆盖

[root@host 下载]# cd nginx-1.20.1/

[root@hos nginx-1.20.1]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module

[root@host nginx-1.20.1]# make

复制nginx-1.20.1下的nginx到原来的nginx目录下,注意nginx-1.20.1中nginx在objs目录下而不是在sbin下面

[root@host nginx-1.20.1]# cd objs/
[root@host objs]# cp nginx /usr/local/nginx/sbin/

测试是否替换成功

[root@host sbin]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@host sbin]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.20.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled

如果出现一下问题需要解决
1、

nginx: [error] open() “/usr/local/nginx/logs/nginx.pid” failed (2: No such file or directory)

解决方法:
1、检查配置文件中是否注释pid,如果注释了请放开。
配置文件路径 /usr/local/nginx/conf/nginx.conf
pid的配置:pid /usr/local/nginx/logs/nginx.pid;
2、查看pid对应的路径下是否存在nginx.pid文件,如果没有则创建一个
3、查看nginx配置是否正确

/usr/local/nginx/sbin/nginx -t

4、如果没有问题,则可以重现启动nginx

/usr/local/nginx/sbin/nginx -s reload

5、如果启动失败
可以先杀死nginx相关的进程后重启

# 杀掉所有nginx进程
killall -9 nginx
# 查看nginx配置是否正确
nginx -t
# 启动容器
nginx -c /usr/local/openresty/nginx/conf/nginx.conf 

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值