1

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!!!

4

1 回答 1

0

您正在尝试通过使用与 PHP 完全相同的 FastCGI 后端来使用 PHP 执行 Perl 脚本。这行不通。PHP 的 FastCGI 后端将仅查找 PHP 代码,并且由于 Perl 脚本中没有 PHP 代码,因此它只会提供与 HTML 文件相同的内容。

相反,您需要有另一个专门用于 Perl 的 FastCGI 后端。有关如何执行此操作的示例或涵盖此主题的许多其他站点之一,请参见此处

于 2020-02-01T15:59:22.793 回答