目录
一、下载nginx源码包
nginx官网
http://nginx.org/en/download.html
二、开始平滑升级
1. 解压nginx源码包
[root@localhost ~]# tar xf nginx-1.20.1.tar.gz
2. 查看老版本nginx的配置
[root@localhost nginx]# ./sbin/nginx -V
nginx version: nginx/1.14.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
configure arguments: --prefix=/nginx --with-http_v2_module
3. 编译新版本nginx
[root@localhost nginx-1.20.1]# ./configure --prefix=/nginx --with-http_v2_module #安装目录指定老版本地址
[root@localhost nginx-1.20.1]# make #不需要make install
4. 备份旧版本nginx
[root@localhost nginx]# mv ./sbin/nginx ./sbin/nginx.old
5. 拷贝新版本nginx
[root@localhost nginx-1.20.1]# cp ./objs/nginx /nginx/sbin/nginx
6. 执行平滑升级命令
[root@localhost nginx-1.20.1]# make upgrade
/nginx/sbin/nginx -t
nginx: the configuration file /nginx/conf/nginx.conf syntax is ok
nginx: configuration file /nginx/conf/nginx.conf test is successful
kill -USR2 `cat /nginx/logs/nginx.pid`
sleep 1
test -f /nginx/logs/nginx.pid.oldbin
kill -QUIT `cat /nginx/logs/nginx.pid.oldbin`
没有报错就安装成功
7. 查看nginx版本号
[root@localhost nginx]# ./sbin/nginx -V
nginx version: nginx/1.20.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
configure arguments: --prefix=/app/baiing/nginx --with-http_v2_module
升级成功!!!