nginx 希望在哪里找到它的模块?

Der*_*har 6 nginx

nginx期望在哪里找到其模块的二进制文件?例如,按照惯例,我应该在哪里安装模块nginx_ajp_module

Mic*_*ton 10

模块路径会因您使用的 Linux 发行版而异。一些发行版(例如基于 Debian 的)可能会将它放在奇怪的地方。

要查找系统上的模块路径,请运行nginx -V--modules-path在输出中查找。例如:

nginx version: nginx/1.10.1
built by gcc 6.1.1 20160510 (Red Hat 6.1.1-2) (GCC) 
built with OpenSSL 1.0.2h-fips  3 May 2016 (running with OpenSSL 1.0.2j-fips  26 Sep 2016)
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules ...
Run Code Online (Sandbox Code Playgroud)

您还应该知道动态模块加载仅在 1.10 开发周期中引入。比这更旧的模块被设计为直接编译到 nginx 中,并且需要更新以进行动态加载。您链接的模块就是这样的模块。请联系其开发人员以获取更多信息。

  • 在我的 Ubuntu Server 16.04.1 系统上,`nginx -V` 不包括 `--modules-path`。 (4认同)

小智 6

nginx -V--modules-path如果 nginx 配置了显式--modules-path参数,则只会显示配置标志。(即,如果您运行./configure --modules-path=/path/to/modules编译nginx的时候,你会看到--modules-path=/path/to/modules在输出nginx -V。)默认位置,如果在编译时没有指定路径,是$NGX_PREFIX/modules。在我的 macOS 系统上,$NGX_PREFIX默认为/usr/local/nginx,因此默认模块路径为/usr/local/nginx/modules; 而 Ubuntu 17.10 将前缀单体分解了一点,并期望模块在/usr/lib/nginx/modules.

与许多 *nix-adjacent 的东西一样,配置在这里优先于约定。您可能会发现最好的办法是自己编译 nginx,在运行时指定--prefix=和/或--modules-path=标志./configure这里这里有一些关于这个过程的好文档。