编译安装平滑升级

平滑升级的步骤

  • 获取之前的编译参数
  • 下载新模块
  • 重新编译软件,加上–add-module=新模块的解压路径
  • 备份原程序并停止服务
  • 把原程序用新程序覆盖
  • 启动新程序

环境说明

主机名IP作用
JLin192.168.23.180Nginx
JiaL192.168.23.161test

nginx新增第三方模块echo-nginx-module

// 获取之前的编译参数
[root@JLin ~]# nginx -V

// 下载新模块echo-nginx-module
[root@JLin ~]# cd /usr/src/
[root@JLin src]# wget https://github.com/openresty/echo-nginx-module/archive/refs/heads/JLin.zip
[root@JLin src]# unzip JLin.zip
[root@JLin src]# ls
debug  echo-nginx-module-JLin  kernels  JLin.zip  nginx-1.20.1  nginx-1.20.1.tar.gz

// 重新编译软件
[root@JLin src]# cd nginx-1.20.1/
[root@JLin nginx-1.20.1]# ./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=/usr/src/echo-nginx-module-JLin
[root@matser nginx-1.20.1]# make

// 停止服务、备份原程序、将原程序替换 并 启动新程序
[root@JLin src]# nginx -s stop && \
> mv /usr/local/nginx/sbin/nginx /tmp/ && \
> cp /usr/src/nginx-1.20.1/objs/nginx /usr/local/nginx/sbin/ && \
> /usr/local/nginx/sbin/nginx 

// 检查是否升级成功
[root@JLin ~]# nginx -V

测试新模块功能

[root@JLin ~]# vim /usr/local/nginx/conf/nginx.conf
server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;
    
        #access_log  logs/host.access.log  main;
    
        location / {
            echo "JLin";
        }

# 检查语法是否有误
[root@JLin ~]# nginx -t
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

[root@nginx ~]# nginx -s reload

验证

[root@JiaL ~]# curl http://192.168.23.180:8080
JLin
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

汉只只

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

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

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

打赏作者

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

抵扣说明:

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

余额充值