Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在nginx上安装模块?_Nginx_Module_Nginx Config - Fatal编程技术网

如何在nginx上安装模块?

如何在nginx上安装模块?,nginx,module,nginx-config,Nginx,Module,Nginx Config,运行nginx-t时,我遇到以下错误: nginx: [emerg] unknown directive "subs_filter_types" in /etc/nginx/sites-enabled/my.site.com.conf:285 nginx: configuration file /etc/nginx/nginx.conf test failed 因此,我需要在nginx文档中安装替换过滤器模块 这表示要运行这些命令: git clone git://github.com/yao

运行nginx-t时,我遇到以下错误:

nginx: [emerg] unknown directive "subs_filter_types" in /etc/nginx/sites-enabled/my.site.com.conf:285
nginx: configuration file /etc/nginx/nginx.conf test failed
因此,我需要在nginx文档中安装替换过滤器模块 这表示要运行这些命令:

git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
./configure --add-module=/path/to/module
yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum -y install nginx-module-substitutions
问题是,我的nginx安装中和 git存储库。我真的不明白。
至少我想知道nginx配置脚本的内容。

您所指的说明是用于编译安装的

假设您想将该模块添加到现有的NGINX安装中,下面是运行该模块的一般步骤

  • 从NGINX.org获取与您安装的版本完全匹配的NGINX,并将其解压缩到系统中,例如,
    /usr/local/src/NGINX
  • git克隆
    NGINX模块的源代码到您的系统中,例如
    /usr/local/src/NGINX模块foo
  • cd/usr/local/src/nginx
    。您将在此处找到
    配置
    脚本。基本上,您将使用相关特定模块的
    config
    位置配置NGINX,因此下一步:
  • /configure--add dynamic module=../nginx module foo--with compat
  • make
  • 作为编译的结果,您将在NGINX源代码的
    objs
    目录中的某处拥有模块的
    .so
    文件。然后将其复制到例如
    /usr/lib64/nginx/modules/
    目录

    要使您现有的NGINX加载模块,请添加
    load_modules modules/foo.so
    位于
    /etc/nginx/nginx.conf
    的最顶端

    您可以解读整个编译方法的许多缺点:一个是在生产系统上安装编译软件(
    gcc
    ),另一个是在升级NGINX或模块时必须重新执行所有这些步骤

    出于上述原因,您可能希望搜索打包安装的第三方模块

    对于CentOS/RHEL系统,您可能希望了解GetPageSpeed repos(订阅软件,我倾向于提及它,因为我是维护人员。但在撰写本文时,CentOS/RHEL 8是免费的。安装您想要的模块时,只需几个命令:

    git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
    ./configure --add-module=/path/to/module
    
    yum -y install https://extras.getpagespeed.com/release-latest.rpm
    yum -y install nginx-module-substitutions
    

    对于基于Debian的系统,可能存在相同的替代PPA。

    只需将前缀subs替换为sub

    对于默认的nginx 1.10.3安装(Ubuntu 16.04.5 LTS)

    nginx-V应该有标志--with-http_sub_模块来使用sub_*指令

    用法示例:

    sub_filter_types   text/html text/css text/xml;
    sub_filter         'needle' 'replacement';
    sub_filter_once    off;
    

    你是说?我不知道。sub(替换)是我得到的。它可能是一样的。或者可能不是。我使用
    Subs\u filter\u types
    而不是
    sub\u filter\u types
    ,得到相同的错误消息,我的Nginx附带了内置的模块。获取我的Nginx版本是什么意思?这是我的版本“nginx版本:nginx/1.14.0(Ubuntu)"我的/usr/local/src中没有任何内容。在/etcnginx中有一个名为modules enabled的文件夹,那是用来做什么的?谢谢你的回复。获取你的nginx版本意味着去nginx.org网站,下载与你当前安装的版本相同的.tar.gz文件。例如,在你的情况下,它是。所以你基本上会
    wgethttp://nginx.org/download/nginx-1.14.0.tar.gz
    然后
    tar zxvf…
    然后将其移动到
    /usr/local/src/nginx
    (位置不必存在,我只是为了保持一致性而将其放置)。许多发行版在编译/安装模块后启用模块时有不同的约定。显然,您的发行版启用了
    模块
    ,对于每个安装的模块,它很可能有
    .conf
    文件,其中包含相同的
    load\u module
    指令。我已经解决了这个问题。但现在,当脚本为r时,我在最后遇到了这个错误安:(我不想禁用它)当然,您需要任何依赖库来编译NGINX。您可能需要检查