[英]"You don't have permission to access this resource." for perl scripts in CGI-Executables/ on Mac OS 11 - Big Sur
I am receiving "You don't have permission to access this resource."我收到“您无权访问此资源”。 for perl scripts in /Library/WebServer/CGI-Executables/
on Mac OS 11 - Big Sur.适用于 Mac OS 11 - Big Sur 上/Library/WebServer/CGI-Executables/
中的 perl 脚本。 I have a simple test script:我有一个简单的测试脚本:
#!/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";
When I execute it from Terminal
, it runs properly and its output is:当我从Terminal
执行它时,它运行正常,它的 output 是:
Content-type: text/html; charset=iso-8859-1
<html><body>Test Page</body></html>
I believe the file permissions for the script:我相信脚本的文件权限:
-rwxr-xr-x 1 <my-username> wheel 170 Aug 31 04:50 test.pl*
are correct.是正确的。
I believe the file permissions for the directory in which the script lives:我相信脚本所在目录的文件权限:
drwxr-xr-x 24 <my-username> wheel 768 Aug 31 18:52 CGI-Executables/
are also correct.也是正确的。
I believe my httpd.conf
is correctly configured:我相信我的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>
and和
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>
While I believe all of this to be correct, clearly, one or more of these beliefs is false, because when I try to open test.pl
in a web browser using http://localhost/cgi-bin/test.pl
I get the error message:虽然我相信所有这些都是正确的,但显然,这些信念中的一个或多个是错误的,因为当我尝试使用http://localhost/cgi-bin/test.pl
在 web 浏览器中打开test.pl
时,我得到错误信息:
Forbidden
You don't have permission to access this resource.
EDIT编辑
After @ikegami 's suggestion that I look at the logs, I find in /usr/local/var/log/httpd/error_log
:在@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
which led me to Apache2: 'AH01630: client denied by server configuration' , and the suggestion that I modify my httpd.conf
, adding:这使我想到了Apache2: 'AH01630: client denied by server configuration' ,并建议我修改我的httpd.conf
,并添加:
Order allow,deny
So, now my httpd.conf
looks like:所以,现在我的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>
But after a brew services restart httpd
, I am still getting the AH01630
error above.但是在brew services restart httpd
之后,我仍然收到上面的AH01630
错误。
It is a kind of attention to details test.这是一种注重细节的测试。
Look at very end of this看看这最后
3035] [client ::1:61483] AH01630: client denied by server configuration: /Library/WebServer/CGI-Executablestest.pl
And look at this看看这个
ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables"
and change it to this并将其更改为
ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables/"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.