gpt4 book ai didi

perl - NGINX 不执行 perl 脚本?

转载 作者:行者123 更新时间:2023-12-04 19:31:51 24 4
gpt4 key购买 nike

我正在运行 NGINXCentos 8我无法让它执行 perl脚本,它只是不断下载脚本。

我在这台服务器上有几个域,它运行 php脚本和这样的罚款。

我已经安装了perl在服务器上,

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

我尝试将此服务器 block 添加到 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;
}

如果不将此位添加到服务器 block ,它只会下载文件;将此位添加到服务器 block 中,我得到一个 502 bad gateway .所以我确定里面有些东西是不正确的。

我几乎完全从 PHP该位的版本,如下所示:
    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;
}

任何想法我做错了什么?谢谢!!!

最佳答案

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

相反,您需要有另一个专门用于 Perl 的 FastCGI 后端。见 here有关如何执行此操作的示例或 one of the many other sites which cover this topic .

关于perl - NGINX 不执行 perl 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60017779/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com