Apache 只显示 /var/www/html 的内容但没有任何其他网站(错误 403)

Apache only showing contents of /var/www/html but no any other websites (error 403)

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

当我在 /etc/apache2/sites-available 中没有定义任何网站并访问我的网站 docker2.mysite.com/info.php 时,我看到 .php 文件的内容执行得很好,但是当我添加一个 docker2.conf 在那个路径和 运行 a2ensite site 然后重新加载 apache,我得到错误 403.

问题似乎是 /var/www/html/ 中的文件被执行了,而其他站点没有 运行ning。

这里是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>

我已经尝试 chownDocumentRoot 更改为 www-data 但它没有改变。

几天前我做了这个并且该网站正在从它自己的路径执行,但我不知道它不工作是什么问题。

默认情况下,您的 apache acl 被整个系统拒绝,并允许 /var/www/html

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

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