首先去Nginx官网下载需要升级的软件包
Nginx官网地址:http://nginx.org/download/
此次示例是把nginx-1.16.1升级为nginx-1.17.0,所以在官网下载了nginx-1.17.0.tar.gz
[root@localhost ~]# wget http://nginx.org/download/nginx-1.17.0.tar.gz
升级步骤:
[root@localhost ~]# tar -xf nginx-1.17.0.tar.gz -C /usr/src
[root@localhost ~]# cd /usr/src/nginx-1.17.0
[root@localhost nginx-1.17.0]# ./configure \
> --prefix=/usr/local/nginx \ #指定安装路径
> --user=nginx \ #指定用户名称
> --group=nginx \ #指定组名称
> --with-http_ssl_module #支持加密功能
[root@localhost nginx-1.17.0]# make
[root@localhost nginx-1.17.0]# cd /usr/local/nginx/sbin/
[root@localhost sbin]# mv nginx nginxold #将nginx-1.16.1的脚本改名为旧脚本
[root@localhost sbin]# cd /usr/src/nginx-1.17.0/objs/
[root@localhost objs]# cp nginx /usr/local/nginx/sbin/ #拷贝新脚本
[root@localhost objs]# cd ..
升级软件,做到这里居然报错了
[root@localhost nginx-1.17.0]# make upgrade
/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: [emerg] getpwnam("nginx") failed
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
make: *** [Makefile:17: upgrade] Error 1
需要修改一下配置文件
[root@localhost nginx-1.17.0]# vim /usr/local/nginx/conf/nginx.con
把这里的#去掉
然后重启nginx服务
[root@localhost nginx-1.17.0]# /usr/local/nginx/sbin/nginx -s reload
再次升级软件
[root@localhost nginx-1.17.0]# make upgrade
/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
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
sleep 1
test -f /usr/local/nginx/logs/nginx.pid.oldbin
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
查看软件版本
[root@localhost nginx-1.17.0]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.17.0
ok升级成功