黑帽联盟

 找回密码
 会员注册
查看: 1183|回复: 0

[基础服务] 解决nginx: [emerg] unknown directive “stream“ in /etc/nginx/nginx.conf

[复制链接]

908

主题

38

听众

3384

积分

管理员

Rank: 9Rank: 9Rank: 9

  • TA的每日心情
    难过
    2026-8-27 20:41
  • 签到天数: 1706 天

    [LV.Master]伴坛终老

    背景
    修改了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

    您需要登录后才可以回帖 登录 | 会员注册

    发布主题 !fastreply! 收藏帖子 返回列表 搜索
    回顶部