perl - 未知指令 "perl_modules"

标签 perl variables nginx module

尝试使用以下 /etc/nginx/nginx.conf 设置启动 nginx 时,出现未知指令“perl_modules”错误:

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    perl_modules perl/lib;

    perl_set $subdomain_uppercase 'sub {
        my $r = shift;
        my $subdomain = $r->subdomain;
        $subdomain = uc($subdomain);
        return $subdomain;
    }';

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

我安装了 perl:

root@0f0babe794c4:/etc/nginx# perl -v

This is perl 5, version 20, subversion 2 (v5.20.2) built for x86_64- linux-gnu-thread-multi
 (with 92 registered patches, see perl -V for more detail)

看起来该模块已在我的 nginx 设置中启用:

root@0f0babe794c4:/etc/nginx# nginx -V
nginx version: nginx/1.9.15
built by gcc 4.9.2 (Debian 4.9.2-10)
built with OpenSSL 1.0.1k 8 Jan 2015
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --add-dynamic-module=debian/extra/njs-1c50334fbea6/nginx --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,--as-needed'

值得注意的是,上面包括--with-http_perl_module=dynamic

我是否缺少启用此 perl 模块以便设置动态变量的额外步骤?

最佳答案

您将 ngx_http_perl_module 安装为动态模块 (--with-http_perl_module=dynamic),因此您需要在 nginx.conf 的开头加载此模块:

load_module /usr/lib/nginx/modules/ngx_http_perl_module.so

我使用了 --modules-path 选项中的路径,因此请检查此目录以获取 http_perl 模块文件的确切名称

关于perl - 未知指令 "perl_modules",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40426657/

相关文章:

django - 使用 Docker Swarm 部署时,nginx 是否应该与 Django 打包到同一个容器中?

perl - 如何从 Perl 测试文件中检查文件的内容?

perl - 使用 TAP::Harness 处理测试,如何在测试退出时打印输出

python - 如何在 Python 中更新变量

http - 配置 Nginx 和 Socket.IO

python - django+nginx部署无法正确加载静态文件

arrays - 如何对 Perl 数组进行分页?

perl - Moose属性如何“扮演”鼠标角色?

c++ - 如何在if语句中定义变量和比较值?

variables - 检测变量的变化并做出相应的响应 [Lua]