简体   繁体   English

Apache权限被拒绝

[英]Apache permission denied

I've just installed a new Apache 2.4.2 with Php fast cgi build on windows. 我刚刚在Windows上安装了一个带有Php fast cgi build的新Apache 2.4.2。

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.

Any ideas what might be the problem? 任何想法可能是什么问题?

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 Random explains 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+. 经过一些实验,我发现了一个细微差别,使得这个问题成为正确的答案,这是Apache 2.3+特有的。 It seems that mod_authz_host directives take precedence over mod_access_compat directives, and this bubbles all the way up the directory tree. 似乎mod_authz_host指令优先于mod_access_compat指令,并且它在目录树中一直向上冒泡。 What this means is that if you are migrating from Apache 2.2 to Apache 2.4 and you use your 2.2 httpd.conf verbatim, it will work. 这意味着如果您从Apache 2.2迁移到Apache 2.4并且您使用2.2 httpd.conf逐字,它将起作用。

If, however, you perform a new install of 2.4 and base your config on the default 2.4 httpd.conf , Allow directives won't work, because the default top level section uses a Require all denied directive instead of Deny from all , and this takes precedence over any subsequent Allow directives higher up the tree. 但是,如果您执行新安装的2.4和底座上的默认2.4你的配置httpd.confAllow指令将无法正常工作,因为默认的顶层部分采用一个Require all denied指令,而不是Deny from all了,这优先于树上方的任何后续Allow指令。 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. 除此之外,如果你将Order / Allow / Deny指令迁移到它们的等效需求,那么你必须有机会所有这些或者你会发现你得到了你没想到的403s。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM