nginx unknown directive “stream“

Table of contents

1. Installation dependencies 

2. Execute the command


 The reason for nginx running error: unknown directive "stream" is mainly because the stream module is not installed. We only need to compile and install the stream module to solve this problem.

1. Installation dependencies 

Install the dependent plugins required for compilation in advance

# gcc安装,nginx源码编译需要
yum install gcc-c++

# PCRE pcre-devel 安装,nginx 的 http 模块使用 pcre 来解析正则表达式
yum install -y pcre pcre-devel

# zlib安装,nginx 使用zlib对http包的内容进行gzip
yum install -y zlib zlib-devel

# OpenSSL 安装,强大的安全套接字层密码库,nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http)
yum install -y openssl openssl-devel

2. Execute the command

In the nginx source code directory, execute the following command to install the stream module.

nginx默认安装的时候没有加载stream模块
需要重新对源文件进行编译、安装,通过添加--with-stream参数指定安装stream模块

./configure --with-stream
make & make install

再次检查nginx.conf配置文件,确认配置无语法错误后,再次尝试启动服务。
nginx -t 检查配置文件是否正确
nginx -c 指定启动的配置文件
The above is the specific method and steps I took to solve this problem. I hope it will be of some reference value for you to encounter this problem.

Guess you like

Origin blog.csdn.net/qq_19309473/article/details/131431435