[Nginx]安装第三方调试模块——echo | #解决异常#unknown directive “echo”

前言

echo 模块/指令: 在Nginx中是一个第三方开发者————agentzh(章亦春)开发的、功能强大的调试工具。

location = /helloworld/ {
	default_type 'text/plain';
	echo 'hello world~ [= /helloworld/]'; # Nginx并没有内置echo这个指令 => 报异常: unknown directive "echo" in [Windows端 nginx 暂不支持 echo 模块的安装]
}
  • 噩耗1: Nginx没有内置 echo 模块
    But,Nginx并没有内置echo这个指令。
    所以,在Nginx没有安装echo模块时,将报如下异常:
2020/10/10 17:37:20 [emerg] 6276#17664: unknown directive "echo" in D:\Program Files(x86)\Nginx\nginx-1.18.0/conf/johnny/proxy_tomcat_servers.conf:51
Windows 系统代码不是开源的,Nginx 没有办法动态链接模块,因此, Nginx 提供的二进制文件和其中包含的模块的使用是受限制的。

Linux OS 安装 echo 模块

模块全名: echo-nginx-module

  • 1 下载 / 解压
    通过下述URL,下载echo-nginx-module模块的.zip版本,并解压
https://github.com/agentzh/echo-nginx-module
  • 2 配置 安装
./configure --prefix=/usr/local/nginx --add-module=/解压出来的echo-nginx-module目录

make -j2 && make install

/usr/local/nginx/sbin/nginx # 启动
  • 3 使用
location /hello {
      echo "$document_root<br/>hello, use echo!";
}

X 参考文献

posted @ 2020-10-10 18:02  千千寰宇  阅读(2255)  评论(0编辑  收藏  举报