实际上,Nginx并无echo这个指令,因此你贸然使用时,天然会提示说没法识别的指令,处理方法有两个:html
方法一是:
从下面链接下载echo-nginx-module模块并安装:
下载以后安装按照普通模块安装便可:
./configure --prefix=/usr/local/nginx --add-module=/dir-to-echo-nginx-modulenginx
安装以后,root权限执行:
make -j2 && make installgit
而后就能够在自定义模块中使用echo指令。
好比在配置文件nginx.conf中添加:
location /hello {
echo "hello, use echo!";
}
方法2是:
不用使用echo指令,直接使用html之类的文件代替,可是url须要添加(.html)后缀名,例如:
location /hello.html {
root html;
index htllo.html;
}
可是在请求时能够不用加后缀名,如:
http://localhost/hellogithub