当前位置:

Nginx版本升级

访客 2024-01-05 1434 0

问题描述:运维安全人员扫出服务器nginx信息披露风险需要升级nginx
一。注意事项

1.Nginx升级,需要备份之前安装的Nginx配置文件等(防止出现意外)将之前的nginx安装路径的打成tar包换到安全路径存储,防止安装过程中目录被覆盖
2.Nginx升级过程中不能直接install会覆盖之前的配置文件(不能直接make&&makeinstall)
3。将Nginx1.16.1进行参数配置和编译,不需要进行安装。

二。升级流程

1.下载(http://nginx.org/en/download.html)linux下载Stableversion下面的nginx-1.22.1pgp这种类型的2.//解压tar-xvfnginx-1.17.5.tar.gz3.nginx配置编译//进入新版本目录cdnginx-1.17.54.//执行配置./configure5.//执行编译(只编译不安装)make6.备份旧版本,复制新版本//备份旧版本文件mv/usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx.old7.//复制新版本文件cpnginx-1.17.5/objs/nginx/usr/local/nginx/sbin/8.重启nginx//测试新版本nginx配置是否正常nginx-t9.//验证nginx是否升级成功nginx-V10.//关掉nginx所有进程killallnginx11.//重启nginx./nginx

三。遇到的问题

编译过程缺少ngx_http_substitutions_filter_module重启过程中出现报错conf某一行找不到configuringadditionalmodulesaddingmodulein/git/ngx_http_substitutions_filter_module/./configure:error:no/git/ngx_http_substitutions_filter_module//configwasfound

四。解决办法
(1)排查发现并未有配置文件格式错误
(2)缺少插件==>安装相关插件依赖
Nginx编译安装第三方模块http_substitutions_filter_module

1、下载模块源码包并解压,最后列出目录位置备用//服务器有外网可以直接拉取[root@MyServer~]#wget-Ongx_http_substitutions_filter_module-master.ziphttps://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/master.zip//服务器无外网github手动下载地址:https://github.com/yaoweibin/ngx_http_substitutions_filter_module/[root@MyServer~]#unzipngx_http_substitutions_filter_module-master.zip[root@MyServer~]#cdngx_http_substitutions_filter_module-master;pwd/root/ngx_http_substitutions_filter_module-master2、在服务器上执行nginx-V查看当前Nginx编译参数,比如:[root@MyServer~]#/usr/local/nginx/sbin/nginx-VTengineversion:Tengine/2.1.2(nginx/1.6.2)builtbygcc4.8.520150623(RedHat4.8.5-4)(GCC)TLSSNIsupportenabledconfigurearguments:--prefix=/usr/local/nginx--with-http_v2_module--with-http_ssl_module--with-http_gzip_static_module--with-http_realip_module--add-module=../ngx_cache_purge-2.3--with-http_sub_module3.加上模块参数,重新编译Nginx找到服务器上原来安装时留下的Nginx源码目录(如果没有请重新下载并解压,此处不赘述),进入目录后,在第②步中的参数基础上新增集成替换模块(请注意前面需要加上./configure):./configure[原有参数]--add-module=/root/ngx_http_substitutions_filter_module-master/./configure--prefix=/usr/local/nginx--with-http_v2_module--with-http_ssl_module--with-http_gzip_static_module--with-http_realip_module--with-http_sub_module--add-module=/root/ngx_http_substitutions_filter_module-master/此处折腾完了可以去执行(二。升级流程的第五步)nginx-v不报错问题解决

文档相关参考地址(侵删)
安装流程1
安装流程2
插件安装
问题解决

发表评论

  • 评论列表
还没有人评论,快来抢沙发吧~