当前位置: 首页 > news >正文

Nginx升级从1.18.0 升级1.21.1(nginx升级到1.21.1)

公司需求:

有个项目需要升级NGIXN

1、首先查看ngxin版本

[root@appcube-0008 nginx-1.21.0]# nginx -V nginx version: nginx/1.18.0 built by gcc 4.8.5 20150623 (EulerOS 4.8.5-28) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sb in/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/lo g/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/ru n/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --wit h-http_auth_request_module --with-http_dav_module --with-http_flv_module --wit h-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --w ith-http_random_index_module --with-http_realip_module --with-http_secure_link _module --with-http_slice_module --with-http_ssl_module --with-http_stub_statu s_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-zlib=/root/setup/zlib-1.2.11 --add-mod ule=/root/setup/headers-more

这里要注意的问题:

后续用到的这两个要注意,可能因为环境的部署不一样,所以路径不一样(有的人喜欢放在opt目录下)

2、下载解压

wget http://nginx.org/download/nginx-1.21.1.tar.gz tar -zxvf nginx-1.21.1.tar.gz cd nginx-1.21.1

3、编译(这里就用到nginx -V看到的从 --prefix开始往后的参数)

[root@appcube-0008 nginx-1.21.1]# ls auto bash.sh CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src [root@appcube-0008 nginx-1.21.1]# cat bash.sh #我这里嫌麻烦改成了shell ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/ng inx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/n ginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-compat --with-file-aio --with-th reads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module -- with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --wi th-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_s tub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream -- with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-zlib=/root/setup/zlib-1 .2.11 --add-module=/root/setup/headers-more

4、make

千万不要执行make install,make install 直接重装了,环境就没了

[root@localhost nginx-1.21.1]# make make -f objs/Makefile make[1]: Entering directory `/setup/nginx-1.21.0' cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ 。。。。 objs/src/http/modules/ngx_http_upstream_keepalive_module.o \ objs/src/http/modules/ngx_http_upstream_zone_module.o \ objs/src/http/modules/ngx_http_stub_status_module.o \ objs/ngx_modules.o \ -ldl -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lpthread -lz \ -Wl,-E sed -e "s|%%PREFIX%%|/opt/nginx|" \ -e "s|%%PID_PATH%%|/var/nginx/logs/nginx.pid|" \ -e "s|%%CONF_PATH%%|/var/nginx/conf/nginx.conf|" \ -e "s|%%ERROR_LOG_PATH%%|/var/nginx/logs/error.log|" \ < man/nginx.8 > objs/nginx.8 make[1]: Leaving directory `/root/setup/nginx-1.21.0'

5、替换

[root@appcube-0008 nginx-1.21.1]# ls auto bash.sh CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src [root@appcube-0008 nginx-1.21.1]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx-1.18.0 [root@appcube-0008 nginx-1.21.1]# cp objs/nginx /usr/local/nginx/sbin/

6、依次启动新的主进程和新的工作进程.

通过ps -ef | grep ngxin 查看

kill -USR2 `cat /var/run/nginx/nginx.pid` #杀死主进程 kill -WINCH `cat /var/run/nginx/nginx.pid.oldbin`

主进程长期不死的情况下直接kill -9 主进程

7、最后结果

8、升级完成

http://www.jsqmd.com/news/586990/

相关文章:

  • 文本输入组件核心讲解与实战
  • 告别残差加法,Kimi 给神经网络换了个 “智能引擎”
  • 如何快速优化显示效果:ColorControl开源工具的完整指南
  • 深度解析AI编舞师:5分钟掌握音乐驱动的3D舞蹈生成技术
  • Harness Engineering 工程实践
  • 实战演练,快马生成天气api调用模块,助力pycharm项目快速集成外部服务
  • 太原找靠谱搬家公司避坑指南|居民/企业搬家认准尖兵,正规专业不踩雷 - 宁夏壹山网络
  • OpenClaw集成Skill教程:2026年云端环境部署、配置大模型百炼APIKey、接入QQ/钉钉/飞书/微信
  • 飞秋Mac版:5分钟搭建跨平台局域网通信的终极解决方案
  • 终极VR开发指南:如何用VRExpansionPlugin快速构建专业级UE4虚拟现实应用
  • 2026年做AI教育加盟的靠谱公司多少钱,为你揭秘费用 - 工业设备
  • ContiNew Admin权限管理实战:基于RBAC模型的用户角色与数据权限配置指南
  • MAX31855热电偶数字转换器--热电偶数字温度计
  • 深聊找做AI学习闭环的AI自习室品牌,哪个口碑好 - 工业品网
  • 为什么你的支付宝立减金会闲置?快速回收的技巧全解读 - 团团收购物卡回收
  • OpenMTP:Mac与Android文件传输的终极免费解决方案
  • 别光调学习率!YOLOv11训练中那些被低估的参数:hsv_h、copy_paste与warmup
  • 三相交流电及其计算
  • Windows下OpenClaw安装全流程:对接Kimi-VL-A3B-Thinking图文模型
  • 【Docker】Docker的安装、使用(安装nginx、mysql、redis)、配置加速镜像、项目部署;查看lastest镜像具体版本并改tag
  • 终极指南:Tantivy全文搜索引擎如何实现17种拉丁语言的高效词干提取技术
  • 欧氏距离 vs 余弦相似度
  • Java面向对象核心:继承与多态深度解析
  • 关于学习的一些网站、深度学习数据集网站、标注工具等等
  • Test_si_rcd
  • 三极管相关电路
  • 电力-端口映射与才茂DTU通信
  • 算力基建工程:NVIDIA产业链下的求职机会——什么是CUDA编程,为什么它成为了2026年的“金饭碗”?
  • 实战演练:基于快马平台生成电商全流程自动化测试并与Jenkins集成
  • Docker容器化部署实战:从零构建Spring Boot微服务镜像