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


当前回答

这花了我一些摆弄,让这个工作在我自己的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>

其他回答

就我而言,

我使用macOS Mojave (Apache/2.4.34)。/etc/apache2/extra/httpd-vhosts.conf文件中的虚拟主机设置有问题。添加了所需的目录标记后,我的问题就解决了。

要求全部批准

希望完整的虚拟主机设置结构将拯救你。

<VirtualHost *:80>
    DocumentRoot "/Users/vagabond/Sites/MainProjectFolderName/public/"
    ServerName project.loc

    <Directory /Users/vagabond/Sites/MainProjectFolderName/public/>
        Require all granted
    </Directory>

    ErrorLog "/Users/vagabond/Sites/logs/MainProjectFolderName.loc-error_log"
    CustomLog "/Users/vagabond/Sites/logs/MainProjectFolderName.loc-access_log" common
</VirtualHost>

你所要做的就是用你确切的ProjectFolderName替换MainProjectFolderName。

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

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

source /etc/apache2/envvars

然后跟在后面看着……

tail -f ${APACHE_LOG_DIR}/error.log

问题出在VirtualHost中,但可能不是

要求全部批准

确认您的配置是正确的,下面是正确的示例

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

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

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

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