当前位置:   article > 正文

CentOS 下Nginx版本升级_centos 升级nginx

centos 升级nginx

1、确认当前nginx版本信息

进入nginx安装目录下, 执行

./sbin/nginx -V
  • 1

可以看到当前nginx的版本信息

nginx version: nginx/1.17.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 
built with OpenSSL 1.1.1i  8 Dec 2020
TLS SNI support enabled
configure arguments: --prefix=/extusr/software/nginx --with-http_ssl_module --with-stream --with-pcre=/extusr/software/nginx-install-package/pcre-8.42 --with-zlib=/extusr/software/nginx-install-package/zlib-1.2.11 --with-openssl=/extusr/software/nginx-install-package/openssl-1.1.1i --add-module=/extusr/software/nginx-install-package/ngx_http_proxy_connect_module-master
  • 1
  • 2
  • 3
  • 4
  • 5

2、去nginx官网下载想要升级的tar包

nginx官方下载地址
在这里插入图片描述
服务器可以连公网的话可以直接wget下载

wget http://nginx.org/download/nginx-1.21.6.tar.gz 

  • 1
  • 2

3、去github获取对应nginx版本的ngx_http_proxy_connect_module-master

https://github.com/chobits/ngx_http_proxy_connect_module
在这里插入图片描述

4、安装包解压

tar zxvf nginx-1.21.6.tar.gz
  • 1

解压之后进入安装目录

cd nginx-1.21.6
  • 1

5、安装文件编译

patch -p1 < /extusr/software/nginx-install-package/ngx_http_proxy_connect_module-master/patch/proxy_connect_rewrite_102101.patch
  • 1
./configure --prefix=/extusr/software/nginx --with-http_ssl_module --with-stream --with-pcre=/extusr/software/nginx-install-package/pcre-8.42 --with-zlib=/extusr/software/nginx-install-package/zlib-1.2.11 --with-openssl=/extusr/software/nginx-install-package/openssl-1.1.1i --add-module=/extusr/software/nginx-install-package/ngx_http_proxy_connect_module-master
  • 1
make
  • 1

6、升级NG

mv /extusr/software/nginx/sbin/nginx /extusr/software/nginx/sbin/nginx-1.17.1
  • 1
cp objs/nginx /extusr/software/nginx/sbin/
  • 1
sudo kill -USR2 `cat /extusr/software/nginx/logs/nginx.pid`
  • 1
sudo kill -WINCH `cat /extusr/software/nginx/logs/nginx.pid.oldbin`
  • 1

7、验证升级后的版本

执行

./sbin/nginx -V
  • 1

可以看到nginx的版本信息已成功升级为1.21.6。至此,大功告成!

nginx version: nginx/1.21.6
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 
built with OpenSSL 1.1.1i  8 Dec 2020
TLS SNI support enabled
configure arguments: --prefix=/extusr/software/nginx --with-http_ssl_module --with-stream --with-pcre=/extusr/software/nginx-install-package/pcre-8.42 --with-zlib=/extusr/software/nginx-install-package/zlib-1.2.11 --with-openssl=/extusr/software/nginx-install-package/openssl-1.1.1i --add-module=/extusr/software/nginx-install-package/ngx_http_proxy_connect_module-master
  • 1
  • 2
  • 3
  • 4
  • 5

8、nginx安装目录为/usr/local/nginx

此外,如果nginx目录为默认目录/usr/local/nginx,则替换下nginx路径即可,示例如下:

tar zxvf nginx-1.21.6.tar.gz
cd nginx-1.21.6
patch -p1 < /extusr/software/nginx-install-package/ngx_http_proxy_connect_module-master/patch/proxy_connect_rewrite_102101.patch
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-stream --with-pcre=/extusr/software/nginx-install-package/pcre-8.42 --with-zlib=/extusr/software/nginx-install-package/zlib-1.2.11 --with-openssl=/extusr/software/nginx-install-package/openssl-1.1.1i --add-module=/extusr/software/nginx-install-package/ngx_http_proxy_connect_module-master
make

mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx-1.14.0
cp objs/nginx /usr/local/nginx/sbin/
sudo kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
sudo kill -WINCH `cat /usr/local/nginx/logs/nginx.pid.oldbin`
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/151086
推荐阅读
相关标签
  

闽ICP备14008679号