nginx之版本升级方法一

转至:https://www.cnblogs.com/sblack/p/12809034.html

非线上业务,纯属测试升级,线上业务不要采用此方法,可以采用官方推荐的平滑升级。

环境

  Linux centos 7.7 nginx-1.10,2

  nginx升级到最新nginx-1.16.1

一,官方下载最新源码

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

二,停掉旧nginx服务

  任意一种方法 kill or pkill or service stop ..... 都可以。

三,查看旧nginx旧编译安装参数,修改旧nginx

  /usr/local/nginx/nginx -V

  ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.40 --with-zlib=/usr/local/src/zlib-1.2.11 --with-openssl=/usr/local/openssl-1.1.0f

 

  mv /usr/local/nginx/nginx nginx.old

四,解压,假设在/home/xxx/目录

  cd nginx-1.16.1

  ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.40 --with-zlib=/usr/local/src/zlib-1.2.11 --with-openssl=/usr/local/openssl-1.1.0f

  make

  只编译不安装 

  cp /home/xxx/nginx-1.16.1/objs/nginx /usr/local/nginx/nginx

五,测试加载配置文件

  /usr/local/nginx/nginx -t -c nginx.conf

  nginx -t -c nginx.conf
  nginx: the configuration file /usr/local/nginx/nginx.conf syntax is ok
  nginx: configuration file /usr/local/nginx/nginx.conf test is successful

  可以常事加载

六,查看新安装当前版本

  nginx -V
  nginx version: nginx/1.16.1
  built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
  built with OpenSSL 1.1.0f  25 May 2017
  TLS SNI support enabled
  configure arguments: --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.40 --with-zlib=/usr/local/src/zlib-1.2.11 --with-openssl=/usr/local/openssl-1.1.0f

七,升级成功,启动

  service nginx start

posted @ 2021-09-17 12:45  study_goup  阅读(3969)  评论(0编辑  收藏  举报