nginx版本升级
环境说明
系统 | 主机名 | ip |
---|---|---|
centos7 | localhost | 192.168.30.130 |
要求:把nginx/1.14.2升级到nginx/1.16.1
- 查看当前版本
[root@localhost ~]# nginx -v
nginx version: nginx/1.14.2
- 结束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
- 把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
- 进行configure配置并编译
[root@localhost nginx-1.16.1]# ./configure --prefix=/usr/local/nginx
[root@localhost nginx-1.16.1]# make
- 把之前的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
- 到/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