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


当前回答

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

其他回答

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

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

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

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

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

我在新服务器上设置虚拟主机时遇到了这个问题,并且站点托管在标准的/var/www/html路径之外。您需要考虑两件主要的事情(例如,假设您正在/opt/my-site中设置一个站点)

在默认的2.4安装中,会显式地拒绝访问根文件系统,然后只允许访问/var/www/html。所以你需要给web服务器从新目录读取的权限,就像这样:

<Directory /opt/mysite>
   Require all granted
</Directory>

完成此操作后,请确保虚拟主机的DocumentRoot位于上面授予访问权限的路径下的某个位置。

<VirtualHost *:80>
        ServerName neatwebsite.com
        DocumentRoot /opt/my-site/html
</VirtualHost>

当我遇到这个问题时,我已经设置好了所有的VirtualHosts,但忘记允许从目录结构中读取(所以我错过了指令)。您需要考虑这两个指令,以及它们如何协同工作。

如果跟踪错误日志并重新加载页面,应该会看到有关确切问题的更多信息。

获取环境变量,这样${APACHE_LOG_DIR}将实际工作…

source /etc/apache2/envvars

然后跟在后面看着……

tail -f ${APACHE_LOG_DIR}/error.log

对于Wamp 3 (Apache 2.4),除了像其他答案中描述的那样让服务器在线之外,在虚拟主机文件conf/extra/httpd-vhosts.conf中 你可能需要更换

Require local

with

Require all granted

如果在httpd.conf中有

Include conf/extra/httpd-vhosts.conf