Nginx新增 echo模块
  X8pnoGTibFPy 2023年11月02日 56 0

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


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

X8pnoGTibFPy
作者其他文章 更多

2023-11-02

2023-11-02

2023-11-02

2023-11-02

2023-11-02

2023-11-02