用yum安装的nginx,报unknown directive “stream”

用yum安装的nginx,报unknown directive “stream”

解决方法:yum install nginx-mod-stream -y

[root@localhost modules]# yum install nginx-mod-stream -y

已安装:
  nginx-mod-stream.x86_64 1:1.20.1-2.el7                                                                                 

安装位置

[root@localhost ~]# ll /usr/lib64/nginx/modules
总用量 176
-rwxr-xr-x 1 root root 179864 6月   2 08:24 ngx_stream_module.so

nginx配置文件引入stream模块

[root@localhost ~]# cat /etc/nginx/nginx.conf
# 加载stream模块
load_module /usr/lib64/nginx/modules/ngx_stream_module.so;
user  nginx;
worker_processes  auto;
...

nginx新版本已经不需要load

[root@localhost ~]# vim /etc/nginx/nginx.conf
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# nginx -t
nginx: [emerg] unknown directive "ELF" in /usr/lib64/nginx/modules/ngx_stream_module.so:4
nginx: configuration file /etc/nginx/nginx.conf test failed
[root@localhost ~]# 
[root@localhost ~]# vim /etc/nginx/nginx.conf
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# nginx -t
nginx: [emerg] module "ngx_stream_module" is already loaded in /usr/share/nginx/modules/mod-stream.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed
[root@localhost ~]# 
[root@localhost ~]# nginx -v
nginx version: nginx/1.20.1
posted @ 2021-09-06 18:18  1769987233  阅读(3273)  评论(0编辑  收藏  举报