nginx版本升级步骤记录

本文详细描述了如何在内网环境中升级nginx版本,包括解压新版本包、迁移配置、解决编译时可能遇到的依赖问题,以及提供两种安装缺失依赖的方案:通过RPM包和手动编译安装OpenSSL、PCRE和zlib。
摘要由CSDN通过智能技术生成

nginx版本升级步骤【内网升级】


一、nginx升级步骤


1.将需要升级的压缩包放入linux服务器(这个需要自己去找对应的版本,这里我就不放链接了)


2.解压下载的nginx压缩包,解压到一个目录


 tar -zxvf nginx-1.24.0.tar.gz 

3.进入旧版本目录,查看nginx版本,和配置文件信息 ./nginx -V
(查看旧版本的信息)

[root@oracle sbin]# pwd
/usr/local/nginx/sbin

执行配置查看命令
[root@oracle sbin]# ./nginx -V
nginx version: nginx/1.24.0
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=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_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_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'



4.在老版本的目录中,执行 ./nginx -V 时,查看配置信息,复制配置信息,到新版本的目录中,进行配置


4.1 在新版本的目录中,执行绿色的可执行文件,./configure 。执行携带上方的配置信息
4.2 执行./configure命令时,查看携带的配置信息, "--with-http_spdy_module" 的配置修改为"--with-http_v2_module", 编译的时候如果报错误1: ./configure: error: invalid option "--with-http_spdy_module" 是因为nginx版本较高,1.9.5已经没有这个模块,取而代之的是--with-http_v2_module。

(客户服务器中,使用 ./nginx -V 查看配置信息,再粘贴到 ./configure 命令后面。防止结构目录不一致,导致的执行错误)
命令:

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_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_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt=‘-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic’


(第四个步骤都的主要意思,设置升级时配置,出现的提示各不相同,但是带感都是缺某个模块或者某个依赖的问题)


5.执行完毕以上命令后,在执行 make 命令。不要执行make install .
这样,最新版本nginx的目录下会多出来一个objs目录



6.对老版本 sbin 目录下的 nginx 进行备份 mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

7.将编译好的 objs 目录下的 nginx 文件(新版本目录下),复制到 /usr/local/nginx/sbin 目录(老版本目录) cp /root/nginx-1.19.7/objs/nginx /usr/local/nginx/sbin/nginx

8.执行 make upgrade 命令。

9.如果make upgrade 指令报错

make: *** [upgrade] Error 1

启动nginx实例的时候要用绝对路径命令,以免以后各种麻烦
-c启动 携带配置文件位置启动
如果不知道配置文件位置,可以执行, ./nginx -t 获取配置文件信息

[root@oracle sbin]# ./nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

将上面获取的配置文件信息,携带到-c命令后面。一起启动
/usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf



二、内网升级nginx缺少依赖解决方案


第一种安装方式(rph安装大量其他依赖包)

1.解压 gcc_pcre_lib.zip 压缩包。

2.进入根目录,/root/gcc_pcre_lib ,目录下为安装包的目录
执行:rpm -Uvh *.rpm --nodeps --force

3.进入到nginx的安装包目录(新版,升级安装最新版本的目录中)
#安装ssl模块
执行:./configure --with-http_ssl_module

4.最后执行
make


第二种安装方式(安装其他依赖包)

安装 OpenSSL:
Nginx 使用 OpenSSL 处理 SSL/TLS 加密。

  • 解压缩 openssl-1.0.1t.tar.gz 包
  • tar -zxvf openssl-1.0.1t.tar.gz
  • cd openssl-1.0.1t 执行./config
  • ./config完成后,执行make

安装 PCRE:
PCRE 是 Perl Compatible Regular Expressions,用于支持 Nginx 的正则表达式功能

  • 解压缩 pcre-8.37.tar.gz 包
  • tar -zxvf pcre-8.37.tar.gz
  • cd pcre-8.37 执行./configure
  • ./configure完成后,执行make

安装 zlib:
zlib 用于支持 Nginx 的 gzip 模块等功能。

  • 解压缩nginx-1.12.2.tar.gz包
  • tar -zxvf nginx-1.12.2.tar.gz
  • cd nginx-1.12.2 执行./configure
  • ./configure完成后,执行make

文中的文件:




在这里插入图片描述

  • 23
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值