![](/img/trans.png)
[英]You don't have permission to access / on this server - Apache 2 on Mac OS X Mojave
[英]"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.