Nginx,如何在启用 ngx_http_sub_module 的情况下启动服务

Nginx, how to start service with ngx_http_sub_module enabled

如何使用此模块启动 Nginx 作为服务?

根据这个documentation,它说:

This module is not built by default, it should be enabled with the --with-http_sub_module configuration parameter.

我不明白在哪里输入这个命令。是nginx service start --with-http_sub_module吗?太混乱了。

当我输入nginx -V时,它显示--with-http_sub_module可用。

如果你在nginx -V输出中看到--with-http_sub_module,你可以确定模块已经内置。所以只需在配置文件中使用它的指令,不需要做任何特殊的加载模块本身的魔法。

现在为什么文档说:

This module is not built by default, it should be enabled with the --with-http_sub_module configuration parameter.

这适用于你自己编译nginx的时候,例如运行 标准 ./configure && make && make install。因此,如果您 运行 ./configure 不带参数,则默认情况下不会安装该模块。

但值得注意的是,大多数 打包的 nginx 构建(您从 yum install nginxapt install nginx 获得的构建)将具有自定义 ./configure 命令,它(如您的情况)可能已经将 --with-http_sub_module 作为配置开关之一。