1.下载想要升级的nginx包
wget http://nginx.org/download/nginx-1.21.6.tar.gz
2.解压nginx压缩包
tar -zxvf nginx-1.21.6.tar.gz
3.进入nginx-1.21.6文件夹下
cd nginx-1.21.6
4.查看原版本nginx 的配置
/usr/local/nginx/sbin/nginx -V
[root@localhost nginx-1.21.6]# /usr/local/nginx/sbin/nginx -V
#nginx的版本
nginx version: nginx/1.20.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
#nginx的配置信息
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre
5.配置新版nginx
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre
6.编译
make
7.移走原先的nginx二进制文件
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx_old
8.替换新编译的文件到原nginx的sbin目录下
cp objs/nginx /usr/local/nginx/sbin/
9.执行升级命令(在解压出的新版本的nginx源文件目录下执行)
make upgrade
[root@localhost nginx-1.21.6]# 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
10.查看是否升级成功
/usr/local/nginx/sbin/nginx -V
由原来的1.20.2已经升级到1.21.6
nginx version: nginx/1.21.6
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre