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]#
