在 mac os x 中的 apache 中使用 CGI 时禁止 403
403 forbidden when use CGI in apache in mac os x
mac 10.12.6
apache的配置
LoadModule cgi_module libexec/apache2/mod_cgi.so
ScriptAliasMatch ^/cgi-bin/((?!(?i:webobjects)).*$) "/Library/WebServer/cgi-bin/"
<Directory "/Library/WebServer/cgi-bin/">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
AddHandler cgi-script .cgi
</Directory>
AddHandler cgi-script .cgi
和文件 ls -l
user:cgi-bin root# ls -l
total 8
-rwxr-xr-x@ 1 user wheel 60 Oct 27 21:57 server.cgi
这是命令行中的测试
root# /library/webserver/cgi-bin/server.cgi
Content-type:text/plain
hello world
如果我去
http://localhost/cgi-bin/server.cgi
它的回应:
Forbidden
You don't have permission to access /cgi-bin/server.cgi on this server.
我已经尝试了我能做的任何事情。
呀哈我找到问题了
这是 Apache 2.4 的问题
您必须检查允许和拒绝规则
查看 http://httpd.apache.org/docs/2.4/upgrading.html#access
在 2.2 中,基于客户端主机名、IP 地址和客户端请求的其他特征的访问控制是使用指令 Order、Allow、Deny 和 Satisfy 完成的。
在 2.4 中,使用新模块 mod_authz_host 以与其他授权检查相同的方式完成此类访问控制。
新指令是 Require:
2.2配置:
Order allow,deny
Allow from all
2.4配置:
Require all granted
mac 10.12.6
apache的配置
LoadModule cgi_module libexec/apache2/mod_cgi.so
ScriptAliasMatch ^/cgi-bin/((?!(?i:webobjects)).*$) "/Library/WebServer/cgi-bin/"
<Directory "/Library/WebServer/cgi-bin/">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
AddHandler cgi-script .cgi
</Directory>
AddHandler cgi-script .cgi
和文件 ls -l
user:cgi-bin root# ls -l
total 8
-rwxr-xr-x@ 1 user wheel 60 Oct 27 21:57 server.cgi
这是命令行中的测试
root# /library/webserver/cgi-bin/server.cgi
Content-type:text/plain
hello world
如果我去
http://localhost/cgi-bin/server.cgi
它的回应:
Forbidden
You don't have permission to access /cgi-bin/server.cgi on this server.
我已经尝试了我能做的任何事情。
呀哈我找到问题了
这是 Apache 2.4 的问题
您必须检查允许和拒绝规则
查看 http://httpd.apache.org/docs/2.4/upgrading.html#access
在 2.2 中,基于客户端主机名、IP 地址和客户端请求的其他特征的访问控制是使用指令 Order、Allow、Deny 和 Satisfy 完成的。
在 2.4 中,使用新模块 mod_authz_host 以与其他授权检查相同的方式完成此类访问控制。 新指令是 Require:
2.2配置:
Order allow,deny
Allow from all
2.4配置:
Require all granted