繁体   English   中英

“您无权访问此资源。” 适用于 Mac OS 11 上 CGI-Executables/ 中的 perl 脚本 - Big Sur

[英]"You don't have permission to access this resource." for perl scripts in CGI-Executables/ on Mac OS 11 - Big Sur

我收到“您无权访问此资源”。 适用于 Mac OS 11 - Big Sur 上/Library/WebServer/CGI-Executables/中的 perl 脚本。 我有一个简单的测试脚本:

#!/usr/bin/perl
print "Content-type: text/html; charset=iso-8859-1\n\n";
print "<html>";
print "<body>";
print "Test Page";
print "</body>";
print "</html>";
print "\n";

当我从Terminal执行它时,它运行正常,它的 output 是:

Content-type: text/html; charset=iso-8859-1

<html><body>Test Page</body></html>

我相信脚本的文件权限:

-rwxr-xr-x   1 <my-username>  wheel    170 Aug 31 04:50 test.pl*

是正确的。

我相信脚本所在目录的文件权限:

drwxr-xr-x  24 <my-username>  wheel   768 Aug 31 18:52 CGI-Executables/

也是正确的。

我相信我的httpd.conf配置正确:

<IfModule !mpm_prefork_module>
        #LoadModule cgid_module lib/httpd/modules/mod_cgid.so                                                                                                          
</IfModule>
<IfModule mpm_prefork_module>
        LoadModule cgi_module lib/httpd/modules/mod_cgi.so
</IfModule>

ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables"

<Directory "/Library/WebServer/CGI-Executables">
    AddHandler cgi-script .cgi .pl .pm
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride None
    Allow from all
    Require all granted
</Directory>

虽然我相信所有这些都是正确的,但显然,这些信念中的一个或多个是错误的,因为当我尝试使用http://localhost/cgi-bin/test.pl在 web 浏览器中打开test.pl时,我得到错误信息:

Forbidden

You don't have permission to access this resource.

编辑

在@ikegami 建议我查看日志之后,我在/usr/local/var/log/httpd/error_log中找到:

[Sat Sep 03 07:55:17.605501 2022] [authz_core:error] [pid 3035] [client::1:61483] AH01630: client denied by server configuration: /Library/WebServer/CGI-Executablestest.pl

这使我想到了Apache2: 'AH01630: client denied by server configuration' ,并建议我修改我的httpd.conf ,并添加:

    Order allow,deny

所以,现在我的httpd.conf看起来像:

ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables"

<Directory "/Library/WebServer/CGI-Executables">
    AddHandler cgi-script .cgi .pl .pm
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride None
    Allow from all
    Order allow,deny
    Require all granted
</Directory>

但是在brew services restart httpd之后,我仍然收到上面的AH01630错误。

这是一种注重细节的测试。

看看这最后

3035] [client ::1:61483] AH01630: client denied by server configuration: /Library/WebServer/CGI-Executablestest.pl

看看这个

ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables"

并将其更改为

ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables/"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM