nginx版本升级

nginx版本升级

环境说明

系统主机名ip
centos7localhost192.168.30.130

要求:把nginx/1.14.2升级到nginx/1.16.1

  1. 查看当前版本
[root@localhost ~]# nginx -v
nginx version: nginx/1.14.2
  1. 结束nginx进程
[root@localhost ~]# ps -ef |grep nginx
root       4337      1  0 20:22 ?        00:00:00 nginx: master process nginx
nginx      4338   4337  0 20:22 ?        00:00:00 nginx: worker process
root       4373   1476  0 20:40 pts/0    00:00:00 grep --color=auto nginx
[root@localhost ~]# pkill nginx
[root@localhost ~]# ps -ef |grep nginx
root       4376   1476  0 20:40 pts/0    00:00:00 grep --color=auto nginx

  1. 把nginx高版本的压缩包拷到服务器上,解压到/usr/local/目录下
[root@localhost ~]# ls
anaconda-ks.cfg      nginx-1.16.1.tar.gz
nginx-1.14.2.tar.gz
[root@localhost ~]# tar -xf nginx-1.16.1.tar.gz -C /usr/local
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
bin  games    lib    libexec  nginx-1.16.1  share
etc  include  lib64  nginx    sbin          src

  1. 进行configure配置并编译
[root@localhost nginx-1.16.1]# ./configure --prefix=/usr/local/nginx
[root@localhost nginx-1.16.1]# make
  1. 把之前的nginx文件备份
    进入/usr/local/nginx/sbin/目录
[root@localhost ~]# cd /usr/local/nginx/sbin/
[root@localhost sbin]# ls
nginx
[root@localhost sbin]# mv nginx nginx-old-copy
[root@localhost sbin]# ls
nginx-old-copy

//然后返回nginx-1.14.2下的objs目录,把新的nginx拷贝过来

[root@localhost ~]# mv /usr/local/nginx-1.16.1/objs/nginx /usr/local/nginx/sbin/ 
[root@localhost ~]# cd /usr/local/nginx/sbin/ 
[root@localhost sbin]# ls
nginx  nginx-old-copy


  1. 到/usr/local/nginx/sbin下查看nginx版本,检出配置文件,启动nginx
[root@localhost sbin]# ./nginx -v
nginx version: nginx/1.16.1
[root@localhost 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@localhost sbin]# ./nginx
[root@localhost sbin]# ss -tanl
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN      0      128     *:80                  *:*                  
LISTEN      0      128     *:22                  *:*                  
LISTEN      0      100    127.0.0.1:25                  *:*                  
LISTEN      0      128    :::22                 :::*                  
LISTEN      0      100       ::1:25                 :::* 

[root@localhost sbin]# nginx -v
nginx version: nginx/1.16.1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值