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

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

其他回答

这花了我一些摆弄,让这个工作在我自己的FreeBSD服务器运行..

FreeBSD 13 Apache 2.4 Python 3.8 LetsEncrypt

. .但最终我想出了一个可行的VirtualHost:

<VirtualHost *:443>

    ServerName mysite.mydomain.com
    DocumentRoot "/usr/local/www/apache24/data/mysite

    WSGIDaemonProcess mysite python-path=/usr/local/www/apache24/data/mysite/venv/lib/python3.8/site-packages/
    WSGIProcessGroup mysite
    WSGIScriptAlias / /usr/local/www/apache24/data/mysite/core/wsgi.py

    SSLEngine on
    SSLCertificateFile "/usr/local/etc/letsencrypt/live/mysite.mydomain.com/cert.pem"
    SSLCertificateKeyFile "/usr/local/etc/letsencrypt/live/mysite.mydomain.com/privkey.pem"
    SSLCertificateChainFile "/usr/local/etc/letsencrypt/live/mysite.mydomain.com/fullchain.pem"

    <FilesMatch "\.(cgi|shtml|phtml|php|py)$">
        SSLOptions +StdEnvVars
    </FilesMatch>

    BrowserMatch "MSIE [2-5]" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0

    CustomLog "/usr/local/www/apache24/data/mysite/log/py-ssl.log" \
        "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    CustomLog "/usr/local/www/apache24/data/mysite/log/py-access.log" combined
    ErrorLog "/usr/local/www/apache24/data/mysite/log/py-error.log"

    <Directory "/usr/local/www/apache24/data/mysite">
        AllowOverride All
        Options +ExecCGI
        Require all granted
        Allow from all
    </Directory

</VirtualHost>

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

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

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

我做了两处改动才完成

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

最后我启动了vm..

我做了与ravisorg建议的OSX 10.10 Yosemite相同的更改,将Apache升级到2.4版本。下面是添加到http.conf中的更改。

<Directory />
    AllowOverride none
    Require all denied
</Directory>

<Directory /Volumes/Data/Data/USER/Sites/>
    AllowOverride none
    Require all granted
</Directory>

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

Require local

with

Require all granted

如果在httpd.conf中有

Include conf/extra/httpd-vhosts.conf

使用Ubuntu时,检查是否启用了CGI模块。如果不是:

sudo a2enmod cgi