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


当前回答

这快把我逼疯了。终于找到了问题所在: 我在错误日志中使用了直接路径,但它们是错误的。

为什么Apache给出一个模糊的(错误的)错误消息?相反,应该使用正确且有用的错误消息,例如:Path for ErrorLog指令“/wrong/ Path /and/filename.log”是无效的。

无论如何,为了修复,确保你的错误日志指令看起来像这样:

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

其他回答

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

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

在花了几个小时后,我自己决定了。

我在vagrant vm中通过cookbook安装Apache/2.4.7 (Ubuntu)。

/etc/apache2/apache2.conf文件默认没有<VirtualHost *:80>元素。

我做了两处改动才完成

added <VirtualHost *:80> 添加 选项索引遵循symlinks AllowOverride所有 允许从所有

最后我启动了vm..

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

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

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

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

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

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