黑帽联盟

标题: 解决nginx: [emerg] unknown directive “stream“ in /etc/nginx/nginx.conf [打印本页]

作者: 定位    时间: 2024-7-12 15:28
标题: 解决nginx: [emerg] unknown directive “stream“ in /etc/nginx/nginx.conf
背景
修改了nginx.conf的配置,增加了stream相关的配置后,重启Nginx,报错

$ systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

$ nginx -t                  
nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:29
nginx: configuration file /etc/nginx/nginx.conf test failed

看错误提示是不能识别stream指令,但是执行了nginx -V后,发现输出内容有相关的stream模块,这就使我很困惑,为啥nginx识别不到呢?



解法

经过查资料和尝试,发现安装nginx-mod-stream这个库可以解决这个问题:

$ sudo yum install nginx-mod-stream


测试下,没问题
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful






欢迎光临 黑帽联盟 (https://bbs.cnblackhat.com/) Powered by Discuz! X2.5