php Apache 权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11992466/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache permission denied
提问by Anonymous
I've just installed a new Apache 2.4.2 with Php fast cgi build on windows.
我刚刚在 Windows 上安装了一个新的 Apache 2.4.2 和 PHP 快速 cgi 构建。
Then I modified the httpd.conf adding the following:
然后我修改了 httpd.conf 添加以下内容:
LoadModule fcgid_module modules/mod_fcgid.so
FcgidInitialEnv PHPRC "C:/SITE/PHP"
AddHandler fcgid-script .php
FcgidWrapper "C:/SITE/PHP/php-cgi.exe" .php
DocumentRoot "C:/SITE/localhost/www"
<Directory "C:/SITE/localhost/www">
Order allow,deny
Allow from all
</Directory>
However when I try to open my site, it says:
但是,当我尝试打开我的网站时,它说:
Forbidden You don't have permission to access / on this server.
Forbidden You don't have permission to access / on this server.
Any ideas what might be the problem?
任何想法可能是什么问题?
回答by Anonymous
This was the correct way to do it: (thanks to DaveRandom)
这是正确的方法:(感谢 DaveRandom)
<Directory "C:/SITE/localhost/www">
Options ExecCGI
AllowOverride all
Require all granted
</Directory>
Dave Randomexplains further:
Dave Random进一步解释说:
After a little experimentation with this, I have discovered the nuance that makes this the correct answer, which is specific to Apache 2.3+. It seems that
mod_authz_hostdirectives take precedence overmod_access_compatdirectives, and this bubbles all the way up the directory tree. What this means is that if you are migrating from Apache 2.2 to Apache 2.4 and you use your 2.2httpd.confverbatim, it will work.If, however, you perform a new install of 2.4 and base your config on the default 2.4
httpd.conf,Allowdirectives won't work, because the default top level section uses aRequire all denieddirective instead ofDeny from all, and this takes precedence over any subsequentAllowdirectives higher up the tree. The long of the short of this is that if you are migrating your Order/Allow/Deny directives to their equivalent Requires, then you must chance all of them or you will find you get 403s you weren't expecting.
在对此进行了一些实验后,我发现了使其成为正确答案的细微差别,这是特定于 Apache 2.3+ 的。似乎
mod_authz_host指令优先于mod_access_compat指令,这在目录树中一直向上冒泡。这意味着如果您从 Apache 2.2 迁移到 Apache 2.4 并httpd.conf逐字使用 2.2 ,它将起作用。但是,如果您执行 2.4 的新安装并将您的配置基于默认 2.4
httpd.conf,则Allow指令将不起作用,因为默认的顶级部分使用Require all denied指令而不是Deny from all,并且这优先于Allow树更高的任何后续指令. 总而言之,如果您将 Order/Allow/Deny 指令迁移到其等效的 Requires,那么您必须尝试所有这些指令,否则您会发现您得到了意想不到的 403。

