nginx缺少"stream" directive is not allowed here

Nginx需要用到stream, 配置后 nginx -t 提示缺少模块

nginx: [emerg] "stream" directive is not allowed here 

如果是源文件安装的话,进入安装目录重新安装,并在末尾加

./configure --prefix=/usr/local/nginx --with-pcre=/app/software/pcre-8.43 --with-zlib=/app/software/zlib-1.2.11 --with-openssl=/app/1.1.1c --with-http_ssl_module --with-stream

如果是centos yum安装的,使用

yum install nginx-mod-stream -y

安装后找到模块位置

ll /usr/lib64/nginx/modules

在nginx.conf 添加模块加载

load_module /你自己的模块位置/ngx_stream_module.so;

保存再查看nginx -t 

不报错就是加载好了

posted @ 2023-03-12 20:55  hanzhang  阅读(3459)  评论(0编辑  收藏  举报