nginx 升级

1.nginx包准备

nginx下载链接:http://nginx.org/en/download.html

上传到对应服务器

2.升级

2.1 查看现有的nginx编译参数

[root@localhost local]# nginx -s stop
[root@localhost local]# nginx -V
nginx version: nginx/1.12.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
configure arguments: --user=nginx --group=nginx --prefix=/data/nginx --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module
[root@localhost local]# 

2.2 按照安装nginx的方法进行安装

只需要到make,千万不要make install

2.2.1 备份旧版本的nginx可执行文件

mv /data/nginx/sbin/nginx /data/nginx/sbin/nginx.old
[root@localhost local]# tar xf nginx-1.20.2.tar.gz 
[root@localhost local]# cd nginx-1.20.2
[root@localhost local]# ./configure --prefix=/data/nginx --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module

[root@localhost local]# make

2.2.2 复制新的nginx二进制文件,进入新的nginx源码包

[root@localhost nginx-1.20.2]# mv /usr/local/nginx-1.20.2/objs/nginx /data/nginx/sbin/
[root@localhost nginx-1.20.2]# ll /data/nginx/sbin/
total 13288
-rwxr-xr-x. 1 root root 6996280 Feb 10 14:02 nginx
-rwxr-xr-x. 1 root root 6605864 Feb 10 11:55 nginx.old
[root@localhost nginx-1.20.2]# cd /data/nginx/sbin
[root@localhost sbin]# ./nginx -v
nginx version: nginx/1.20.2
[root@localhost sbin]# pwd
/data/nginx/sbin

2.2.3 重做软连接,删除二进制包

[root@localhost sbin]# rm -rf /usr/local/bin/nginx
[root@localhost sbin]# ln -s /data/nginx/sbin/nginx /usr/local/bin/nginx 
[root@localhost sbin]# nginx -v
nginx version: nginx/1.20.2
[root@localhost sbin]# nginx -t
nginx: the configuration file /data/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /data/nginx/conf/nginx.conf test is successful
[root@localhost sbin]# nginx
[root@localhost sbin]# rm -rf /usr/local/nginx-1.20.2
[root@localhost sbin]# 

Last modification:March 10, 2022
如果觉得我的文章对你有用,请随意赞赏