当我试图通过浏览器访问localhost时,我得到这个错误。

AH01630: client denied by server configuration

我检查了我的网站文件夹权限使用:

sudo chmod 777 -R *

这是我的配置文件:

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /home/user-name/www/myproject
<Directory />
    Options FollowSymLinks
    AllowOverride all
    Allow from all
</Directory>

<Location />
  Allow from all
  Order Deny,Allow
</Location>

<Directory  /home/user-name/www/myproject/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride all
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride all
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>


当前回答

如果您在windows操作系统的WampServer上使用Apache 2.4。

请在记事本中打开“http -vhosts.conf”文件。

C:\wamp64\bin\apache\apache2.4.37\conf\extra\https-vhosts.conf 

如果您无法找到以上文件。查看下面的截图

 <VirtualHost *:80>
     ServerName localhost
     DocumentRoot c:/wamp64/www
     <Directory  "c:/wamp64/www/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

在上述代码中替换

Require local

with

Require all granted

然后保存。重启Apache服务后重试。

其他回答

...
<IfVersion < 2.4>
   Order allow,deny
   Allow from all
</IfVersion>
<IfVersion >= 2.4>
   Require all granted
</IfVersion>
...

我还有一个可能对某人有用的。 从PHP 5.6 => 7.0升级后收到相同的错误消息。我们已经更改了PHP上传设置,并且在复制后忘记更改。 尽管我当时没有上传图像,但Silverstripe(我们的CMS)拒绝保存并抛出错误。增加图像上传大小,它直接工作。

如果您有https主机,那么不要忘记使ssl配置也要求所有授予的更改。

此外,有时检查apache用户的权限也很有用:

# ps -eFH | grep http # get the username used by httpd
...
apache   18837  2692  0 119996 9328   9 10:33 ?        00:00:00     /usr/sbin/httpd -DFOREGROUND
# su -s/bin/bash apache # switch to that user
bash-4.2$ whoami
apache
bash-4.2$ cd /home
bash-4.2$ ls
bash-4.2$ cd mysite.com
bash-4.2$ ls
bash-4.2$ cat file-which-does-not-work.txt

如果您在windows操作系统的WampServer上使用Apache 2.4。

请在记事本中打开“http -vhosts.conf”文件。

C:\wamp64\bin\apache\apache2.4.37\conf\extra\https-vhosts.conf 

如果您无法找到以上文件。查看下面的截图

 <VirtualHost *:80>
     ServerName localhost
     DocumentRoot c:/wamp64/www
     <Directory  "c:/wamp64/www/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

在上述代码中替换

Require local

with

Require all granted

然后保存。重启Apache服务后重试。

因为这个线程是在搜索提到的错误时弹出的第一件事,我想为这个错误添加另一个可能的原因:你可能有mod_evaving活动,客户端看到这个错误只是越过了mod_evaving .conf中配置的限制

如果您突然为一个以前没有任何问题且其他内容都没有更改的客户端得到这个错误,那么这是一个特别值得研究的原因。

(如果mod_evaded是原因,那么错误将自行消失,如果客户端只是暂时停止尝试访问站点;然而,这可能是一个迹象,你设置了太紧的限制)