Nginx新增 echo模块

Nginx在已安装的情况下新增 echo 模块

1 下载需要的echo模块

# wget https://github.com/openresty/echo-nginx-module/archive/v0.61.tar.gz
# tar xf v0.61.tar.gz -C /usr/src/
# ls
debug                   kernels       nginx-1.12.0.tar.gz
echo-nginx-module-0.61  nginx-1.12.0  v0.61.tar.gz

2 进入源码目录

# cd nginx-1.12.0

3 查看原有编译选项并复制

# nginx -V
nginx version: nginx/1.12.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
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 --add-module=/usr/local/nginx/echo-nginx-module-0.61/

然后复制 --prefix后面的

4 生成 Makefile,为下一步的编译做准备,注意这里很关键,要加上之前已经安装好的模块。

# ./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/local/nginx/echo-nginx-module-0.61/ --add-modure=/usr/local/nginx/sbin/nginx

5 开始编译,但别安装 (make install会直接覆盖安装)

# make

6 注意先备份一下之前老的,手动安装一下。

# mv /usr/local/nginx/sbin/nginx{,-A}

7 在objs查找nginx然后移到/usr/local/nginx/sbin/下

# find / -name objs
/usr/src/nginx-1.12.0/objs
# cd /usr/src/nginx-1.12.0/objs/
# ls
addon         nginx              ngx_auto_headers.h  src
autoconf.err  nginx.8            ngx_modules.c
Makefile      ngx_auto_config.h  ngx_modules.o
# mv /usr/src/nginx-1.12.0/objs/nginx /usr/local/nginx/sbin/

说明

增加模块是这样的步骤
那么升级也是这个步骤

验证

就在配置文件里修改location

        location / {
            root   html;
            echo   'A';
            index  index.html index.htm;
        }
                location = /abc {
            echo 'B';
            root html;
            index index.html;
        }

# nginx -s reload //刷新配置文件

//然后另外开启一个终端
# curl http://192.168.99.128/abcd
A
# curl http://192.168.99.128/ab
A
# curl http://192.168.99.128/abc
B
# curl http://192.168.99.128/abcd
A

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值