You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS 11 Big Sur中CGI-Executables下Perl脚本权限访问问题

解决MacOS 11 Big Sur下CGI脚本权限错误(AH01630)

核心问题定位

从错误日志能看到关键异常:

AH01630: client denied by server configuration: /Library/WebServer/CGI-Executablestest.pl

注意到路径里CGI-Executables和test.pl直接拼接在一起,缺少分隔斜杠——这是服务器找不到文件、进而返回权限错误的根本原因。

修复步骤

1. 修正ScriptAlias路径配置

打开httpd.conf,找到ScriptAlias配置行,给目标目录路径末尾加上斜杠:

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

斜杠会让服务器正确拼接请求路径,将/cgi-bin/test.pl映射为/Library/WebServer/CGI-Executables/test.pl。

2. 启用正确的CGI模块

MacOS Big Sur默认使用mpm_event模块(非prefork模式),需要启用mod_cgid而非mod_cgi。修改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>

解开mod_cgid的注释,确保非prefork模式下加载正确的CGI模块。

3. 确保Web服务器用户有执行权限

Apache在MacOS下以_www用户运行,需要保证该用户对CGI目录和脚本拥有读取、执行权限:

# 递归修改目录组权限
sudo chgrp -R _www /Library/WebServer/CGI-Executables/
# 修改脚本权限,确保其他用户可执行
sudo chmod o+x /Library/WebServer/CGI-Executables/test.pl

4. 重启Apache服务

sudo apachectl restart

验证

再次访问http://localhost/cgi-bin/test.pl,应该能正常显示Test Page内容。

内容的提问来源于stack exchange,提问作者P. James Norris

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 20:48:19