当我试图通过浏览器访问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>


当前回答

有没有人想过wamp服务器默认不包括httpd-vhosts.conf文件。 我的方法是删除下面的注释

 conf
  # Virtual hosts
  Include conf/extra/httpd-vhosts.conf

在httpd.conf文件中。 仅此而已。

其他回答

问题可能是指令不在<目录>下

https://httpd.apache.org/docs/2.4/mod/mod_authz_host.html#requiredirectives

该指令可以在< Directory>, < Files>,或< Location> section以及.htaccess文件中引用,以控制对服务器特定部分的访问。访问可以基于客户端主机名或IP地址进行控制。

再次检查DocumentRoot路径是否正确。这可能会导致此错误。

对于那些像我一样被这个错误困住的人,上面没有任何帮助:检查error.log中的问题文件夹是否确实存在于您的服务器上。我的是由Django在错误的地方自动生成的(被静态根弄乱了,然后是manage.py collectstatic)。不知道为什么不能正确地指出错误。

除了在其他答案中提到的缺少Order和Allow指令外,还要注意DirectoryMatch指令的不匹配正则表达式也可能导致此错误。

如果请求的路径是/home/user-foo1bar/www/myproject/下面的matcher将不匹配

<DirectoryMatch "/home/user-[a-z]+/www/myproject/">
...
</DirectoryMatch>

因此,即使是有效的访问配置也可能导致此错误。

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

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

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