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


当前回答

确保包括任何特定于用户的配置!

如果这一页上的其他答案都不适合你,下面是我在几个小时的挣扎后遇到的。

我使用了特定于用户的配置,在/private/etc/apache2/extra/httpd-userdir.conf中将Sites指定为我的UserDir。但是,我被禁止访问端点http://localhost/~jwork/。

我可以在/var/log/apache2/error_log中看到对/Users/jwork/Sites/的访问被阻止。但是,我被允许通过http://localhost/访问DocumentRoot。这表明我没有权限查看~jwork用户。但据我所知,ps aux | egrep '(apache|httpd)'和lsof -i:80, apache是为jwork用户运行的,所以很明显没有使用我的用户配置编写一些东西。

给定一个名为jwork的用户,下面是我的配置文件:

二等兵/ etc / apache2 \用户/ jwork上。

<Directory "/Users/jwork/Sites/">
    Require all granted
</Directory>

这个配置完全有效。然而,我发现我的用户配置没有被包括在内:

/私人/ etc /输入/多/ httpd-userdir.conf

## Note how it's commented out by default.
## Just remove the comment to enable your user conf.
#Include /private/etc/apache2/users/*.conf

注意,这是userdir conf文件的默认路径,但正如您将在下面看到的,它是在httpd.conf中可配置的。确保下列行已启用:

/ / etc / apache2 /私人httpd.conf

Include /private/etc/apache2/extra/httpd-userdir.conf

# ...

LoadModule userdir_module libexec/apache2/mod_userdir.so

其他回答

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

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

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

如果你像我一样尝试了上面所有的答案,但都没有帮助,记得检查你的apache2.conf是否有像IncludeOptional conf-enabled/*.conf这样的行,然后检查该文件夹中的每个.conf文件。

我的有一个security.conf文件,其中包括这部分(需要删除/修改,以不阻止我需要运行的.php文件):

<FilesMatch "^(wp-config\.php|php\.ini|php5\.ini|install\.php|php\.info|readme\.md|README\.md|readme\.html|bb-config\.php|\.htaccess|\.htpasswd|readme\.txt|timthumb\.php|error_log|error\.log|PHP_errors\.log|\.sv$
    Require all denied
</FilesMatch>

我不知道这个文件来自哪里,除非在某个时候我掉进了一个兔子洞,试图保护我的apache配置,找到这个conf,添加它,然后完全忘记了它。

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

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

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

Require local

with

Require all granted

如果在httpd.conf中有

Include conf/extra/httpd-vhosts.conf