I have configured nginx to use a specific version of Perl.

$ sudo /opt/nginx/sbin/nginx -V
nginx version: nginx/0.8.54
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-46)
TLS SNI support disabled
configure arguments: --with-debug --with-http_ssl_module --with-md5=auto/lib/md5 --with-sha1=auto/lib/sha1 --with-perl=/opt/perl/bin/perl --with-http_gzip_static_module --user=apache --group=apache --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --prefix=/opt/nginx

I created two Perl modules based on EmbeddedPerlMinifyJS: MinifyJS.pm and MinifyCSS.pm which are in the same directory as the nginx.conf file. Inside the http section of the config file I have the following four lines:

perl_require JavaScript/Minifier.pm;
perl_require CSS/Minifier.pm;
perl_require MinifyJS.pm;
perl_require MinifyCSS.pm;

In my server section I have the following:

location ~ \.js$ {
    perl MinifyJS::handler;

location ~ \.css$ {
    perl MinifyCSS::handler;

When I start nginx, I get an error about "perl_require".

$ sudo /opt/nginx/sbin/nginx
[emerg]: unknown directive "perl_require" in /opt/nginx/conf/nginx.conf:31

So how do I configure nginx to use the embedded Perl?

(BTW, "perl_modules" also throws an unknown directive.)

1 Answer 1


I saw the answer immediately after posting. You have to add --with-http_perl_module (and possibly --with-perl_modules_path) when running configure.

This was found at EmbeddedPerlModule in the section entitled "Building Module at Compile-time".

  • Mmm, how do you re-configure perl like this? I'm getting the same error - but I'm unsure of how to tweak Perl. I installed via apt-get, so its a bit new to me :) Oct 24, 2015 at 10:03
  • 1
    @AndrewNewby I compiled Perl from source code. Jan 7, 2016 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .