前言
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
ginx-1.18.0/conf/johnny/proxy_tomcat_servers.conf:51
- 噩耗2:Windows端暂不支持安装 echo 模块
(网络博客的echo模块的安装教程,均是针对Linux端的) ————2020.10.10
参见本文:
windows nginx echo 模块安装 - CSDN
how to install nginx module on windows system nginx - stackoverflow
Windows 系统代码不是开源的,Nginx 没有办法动态链接模块,因此, Nginx 提供的二进制文件和其中包含的模块的使用是受限制的。
![](https://img2020.cnblogs.com/blog/1173617/202010/1173617-20201010175440908-718663555.png)
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!";
}