Nginx模塊開發時unknown directive "echo"的處理

 實際上,Nginx並無echo這個指令,因此你貿然使用時,天然會提示說沒法識別的指令,處理方法有兩個:html


方法一是:
從下面鏈接下載echo-nginx-module模塊並安裝:

https://github.com/agentzh/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

相關文章
相關標籤/搜索