Nginx 安装 echo-nginx-module 模块

Nginx-echo 模块可以在 Nginx 中用来输出一些信息,是在测试排错过程中一个比较好的工具!

1、下载压缩包:

wget https://github.com/openresty/echo-nginx-module/archive/v0.61.tar.gz

2、解压:

tar zxf v0.61.tar.gz

3、进入 nginx 目录,重新编译安装:

./configure --add-module=../echo-nginx-module
make && make install

4、安装完成后,查看当前 Nginx 详细信息:

[root@Centos nginx]# ./sbin/nginx -V
nginx version: nginx/1.14.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
configure arguments: --prefix=/usr/local/nginx --add-module=/opt/echo-nginx-module-0.61
[root@Centos nginx]# 

5、重启 Nginx,使模块生效:

[root@Centos nginx]# ./sbin/nginx -s reload

6、测试:

(1)在 nginx.conf 添加一个 location:

location /test {
    echo "hello world"
}

(2)使用 curl 访问测试:

[root@Centos conf]# curl http://localhost:8000/test
hello world
[root@Centos conf]# 
艺无止境,诚惶诚恐, 感谢开源贡献者的努力!!
原文地址:https://www.cnblogs.com/d0usr/p/12470796.html