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


当前回答

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

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

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

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

其他回答

这让我抓狂了一天半,但我找到了一个解决方案,如果所有其他解决方案都不成功的话。

这是针对macOS的。

进入活动监视器(重点搜索:活动) 在活动监视器中搜索httpd, httpd是Apache服务 选择root用户的目录,单击左上方的X关闭。

在这一点上,我立即停止得到403个错误,一切都开始正常工作。奇怪的是,我甚至没有重新启动apache它只是工作,我猜它重新启动自己当我去我的本地主机,我真的不知道,但我猜问题是apache实际上没有重新启动时,使用apachectl重启,或停止或启动。希望这能帮助到一些人。

获得问题的解决方案,需要在apache2.conf文件中进行更改,之后它将工作, /etc/apache2/apache2.conf中的旧代码

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

改为

 <Directory /var/www/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>

之后,为了让Apache理解重写规则,我们首先需要激活mod_rewrite。它已经安装了,但是在默认的Apache安装中禁用了它。使用a2enmod命令启用模块:

$ sudo a2enmod rewrite

这将激活模块或提醒您模块已启用。要使这些更改生效,请重新启动Apache。

$ sudo systemctl restart apache2

终于对我有用了。

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

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

source /etc/apache2/envvars

然后跟在后面看着……

tail -f ${APACHE_LOG_DIR}/error.log

如果您有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

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

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

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