返回顶部

nginx: [emerg] unknown directive "echo"

nginx: [emerg] unknown directive "echo" 

问题现象:

#nginx -t
nginx: [emerg] unknown directive "echo" in /apps/nginx-1.18.0/conf.d/p.conf:24
nginx: configuration file /apps/nginx-1.18.0/conf/nginx.conf test failed

原因缺少echo 模块,需重新编译解决

复制代码
#cd /apps/nginx-1.18.0
#yum -y install git
#git clone https://github.com/openresty/echo-nginx-module.git
#./configure --prefix=/apps/nginx-1.18.0 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --add-module=/apps/nginx-1.18.0/echo-nginx-module

#make -j 2 && make install
#nginx -t
nginx: the configuration file /apps/nginx-1.18.0/conf/nginx.conf syntax is ok
nginx: configuration file /apps/nginx-1.18.0/conf/nginx.conf test is successful

复制代码

测试验证

复制代码
#systemctl daemon-reload
#systemctl restart nginx
#curl mp.weirui.vip
/main -L hello world,main--> 10.0.0.117 sub1 sub2 took 2.011 sec for total.
复制代码

配置如下

复制代码
#cat /apps/nginx-1.18.0/conf.d/p.conf
server {
        listen       80;
        root /apps/nginx-1.18.0/html;
        server_name mp.weirui.vip;
        access_log  logs/vip-access.log;
        error_log  logs/vip-error.log;
        location / {
            stub_status;
            index  txt json doc index.html index.htm;
        }
        location /main {
            index index.html;
            default_type text/html;
            echo "hello world,main-->";
            echo $remote_addr ;
            echo_reset_timer;
            echo_location /sub1;
            echo_location /sub2;
            echo "took $echo_timer_elapsed sec for total.";
        }
        location /sub1 {
            echo_sleep 1;
            echo sub1;
        }
        location /sub2 {
            echo_sleep 1;
            echo sub2;
        }
}
复制代码

 

posted @   九尾cat  阅读(1183)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示

目录导航