NGINX 不执行 perl 脚本?

问题描述 投票:0回答:2

我在

NGINX
上运行
Centos 8
,但无法让它执行
perl
脚本,它只是不断下载脚本。

我在这台服务器上有几个域,它运行

php
脚本等等。

我已经在服务器上安装了

perl

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

我尝试将此服务器块添加到

conf.d
文件中:

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;
    }

如果没有将此位添加到服务器块,它只是下载文件;将这一点添加到服务器块后,我得到一个

502 bad gateway
。所以我确信里面有些东西是不正确的。

我几乎完全从

PHP
版本的bit中获取它,它看起来像这样:

    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;
    }

你知道我做错了什么吗?谢谢!!!

perl nginx centos fastcgi centos8
2个回答
0
投票

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

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


0
投票

您还可以使用我的项目,它在很多方面类似于

php-fpm
和Apache的
mod_fcgid
,但可以与支持FastCGI启动协议的所有内容一起使用(包括
CGI::Fast
):https://github.com/vdudouyt/ std-fpm

© www.soinside.com 2019 - 2024. All rights reserved.