php - Apache 权限被拒绝

标签 php apache permissions httpd.conf

我刚刚安装了一个新的 Apache 2.4.2,在 Windows 上构建了 Php fast cgi。

然后我修改了 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>

但是,当我尝试打开我的网站时,它显示:

Forbidden 您无权访问此服务器上的/。

任何想法可能是什么问题?

最佳答案

这是正确的方法:(感谢 DaveRandom)

<Directory "C:/SITE/localhost/www">
    Options ExecCGI
    AllowOverride all
    Require all granted
</Directory>

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_host directives take precedence over mod_access_compat directives, 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.2 httpd.conf verbatim, it will work.

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. 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.

关于php - Apache 权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11992466/

相关文章:

php - 打印下拉菜单的可见名称而不是其值名称

php - 在 laravel 中解码和移动 base64 编码的图像

php - 如何使用 mysqli 和 PHP 获取多个值的数据 Categorywise

python - Trac 使用数据库身份验证

git - Mercurial:忽略文件权限/模式(chmod)更改

php - 在 CMS 中选择页面 View /布局

apache - 启动部署架构-在没有Apache的情况下运行Glassfish V3前奏

mysql - OTRS - 新电话票 - 从 AD 添加 CustomerUser (CustomerID) 缓慢

c++ - 如何复制文件并继承Windows EFS?

sharepoint - 如何以编程方式确定 SharePoint 中 Web 的 3 个权限组访问者/成员/所有者?