nginx之版本升级方法一

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

环境

  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 @   sblack  阅读(20477)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
点击右上角即可分享
微信分享提示