【问题标题】:Apache only showing contents of /var/www/html but no any other websites (error 403)Apache 仅显示 /var/www/html 的内容,但不显示任何其他网站(错误 403)
【发布时间】:2024-04-30 05:00:02
【问题描述】:

我已经在我的 Docker Ubuntu 容器中安装了 PHP+Apache,但是我遇到了一个问题:

当我在/etc/apache2/sites-available 中未定义任何网站并访问我的网站docker2.mysite.com/info.php 时,我看到.php 文件的内容执行良好,但是当我在该路径中添加docker2.conf 并运行a2ensite site 时重新加载 apache,出现错误 403。

问题似乎是/var/www/html/ 中的文件已执行,而其他站点未运行。

这里是docker2.conf 内容:

<VirtualHost *:80>
        ServerName docker2.mysite.com

        ServerAdmin webmaster@docker2
        DocumentRoot /home/docker2
        <Directory />
        DirectoryIndex index.html
        </Directory>

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

</VirtualHost>

我试过chowning DocumentRootwww-data,但它没有改变。

几天前我已经这样做了,该网站正在按照自己的路径执行,但我不知道它不工作的问题是什么。

【问题讨论】:

    标签: docker apache ubuntu


    【解决方案1】:

    默认情况下,你的 apache acl 拒绝所有你的洞系统,并允许表单 /var/www/html

    根据您的版本添加allow from allrequire all granted

            <Directory /home/docker2>
                DirectoryIndex index.html
                Require all Granted
            </Directory>
    

    【讨论】:

    • 谢谢,但参数all 应该小写。我刚刚提到,如果将来有人会阅读您的答案,请检查正确答案。