perlnginxcentosfastcgicentos8

NGINX not executing perl scripts?


I'm running NGINX on Centos 8 and I can't get it to execute a perl script, it just keeps downloading the script.

I have several domains on this server and it runs php scripts and such fine.

I have installed perl on the server,

"This is perl 5, version 26, subversion 3 (v5.26.3) built for x86_64-linux-thread-multi"

I tried adding this server block to the conf.d file:

location ~ \.pl|cgi$ {
        try_files $uri =404;
        fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.cgi;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

Without this bit added to the server block, it simply downloads the file; with this bit added to the server block, I get a 502 bad gateway. So I'm sure something in there is incorrect.

I took it almost exactly from the PHP version of the bit, which looks like this:

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index   index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

Any ideas what I'm doing wrong? Thank you!!!


Solution

  • You can also use my project which is similar to php-fpm and Apache's mod_fcgid in many aspects, but works with everything that supports FastCGI startup protocol (including CGI::Fast): https://github.com/vdudouyt/std-fpm