nginx平滑升级

nginx平滑升级

平滑升级:升级版本、增加新功能

1.获取老版本的编译信息

2.老版本备份

3.编译新版本或者新功能(不能执行make install)

4.手动替换新版本并重启

5.验证新版本

添加echo模块

[root@RHEL8 ~]# ls     //老版本为1.22.1
anaconda-ks.cfg       php-8.2.9 php-8.2.9.tar.xz        nginx-1.22.1                      uploadnginx-1.22.1.tar.gz         
nginx-1.24.0.tar.gz
//下载1.24.0作为升级版本
[root@RHEL8 ~]# wget http://nginx.org/download/nginx-1.24.0.tar.gz

进入github.com下载更新模块

请添加图片描述请添加图片描述

[root@RHEL8 ~]# yum -y install git

//克隆模块
[root@RHEL8 ~]# git clone https://github.com/openresty/echo-nginx-module.git
Cloning into 'echo-nginx-module'...
remote: Enumerating objects: 3061, done.
remote: Counting objects: 100% (43/43), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 3061 (delta 21), reused 30 (delta 12), pack-reused 3018
Receiving objects: 100% (3061/3061), 1.18 MiB | 1.75 MiB/s, done.
Resolving deltas: 100% (1645/1645), done.
[root@RHEL8 ~]# ls
anaconda-ks.cfg                   php-8.2.9 php-8.2.9.tar.xz
echo-nginx-module                 nginx-1.22.1                      
uploadnginx-1.22.1.tar.gz         nginx-1.24.0.tar.gz

[root@RHEL8 ~]# tar xf nginx-1.24.0.tar.gz
[root@RHEL8 nginx-1.24.0]# ls
auto     CHANGES.ru  configure  html     man     src
CHANGES  conf        contrib    LICENSE  README

//查看老版本编译参数
[root@RHEL8 nginx-1.24.0]# nginx -V
nginx version: nginx/1.22.1
built by gcc 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC) 
built with OpenSSL 1.1.1k  FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log

[root@RHEL8 nginx-1.24.0]# ./configure --help | grep add-module
  --add-module=PATH                  enable external module     //添加模块
[root@RHEL8 nginx-1.24.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --add-module=../echo-nginx-module

//备份老版本
[root@RHEL8 ~]# cp /usr/local/nginx/sbin/nginx /opt/nginx-20231020
[root@RHEL8 nginx-1.24.0]# make   //编译
[root@RHEL8 nginx-1.24.0]# ls
auto     CHANGES.ru  configure  html     Makefile  objs    src
CHANGES  conf        contrib    LICENSE  man       README
[root@RHEL8 nginx-1.24.0]# cd objs/
[root@RHEL8 objs]# ls
addon         nginx(主程序在这里) ngx_auto_headers.h  src
autoconf.err  nginx.8            ngx_modules.c
Makefile      ngx_auto_config.h  ngx_modules.o

//查看主程序大小
[root@RHEL8 objs]# ll /usr/local/nginx/sbin/nginx 
-rwxr-xr-x. 1 root root 6192528 Oct 16 22:45 /usr/local/nginx/sbin/nginx
[root@RHEL8 objs]# ll objs/nginx
-rwxr-xr-x. 1 root root 6740696 Oct 20 23:22 objs/nginx

[root@RHEL8 objs]# nginx -s stop; \cp nginx /usr/local/nginx/sbin/nginx;nginx
[root@RHEL8 objs]# nginx -v   //平滑升级新版本成功
nginx version: nginx/1.24.0

[root@RHEL8 objs]# vim /usr/local/nginx/conf/nginx.conf
 location / {
            echo "hello world";
            root   html;
            index index.php index.html index.htm;
        }
[root@RHEL8 objs]# nginx -t    //echo模块添加成功
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

疑犯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值