首页 > 解决方案 > 更改 DocumentRoot 后 403 Forbidden

问题描述

所以,我尝试在一台机器上运行一个域、一个子域和另一个域。我为每个站点设置了一个 conf 文件:

<VirtualHost *:80>
        ServerName websitea.com
        ServerAlias www.websitea.com
        DocumentRoot /var/www/html/weba
</VirtualHost>

<Directory /var/www/html/weba>
  Order allow,deny
  Allow from all
  Require all granted
</Directory>

在 apache2.conf 中也可以找到相同的文件夹配置(我尝试过使用它),并且所有站点的配置都相同。

问题是,在放置此 DocumentRoot 并禁用 000-default.conf 后,我得到 403 禁止。

到目前为止我尝试过的事情:

但没有一个会工作......

编辑:我发现该网站进入 /www/var/html/ 即使域设置为进入 /www/var/html/weba,但 DocumentRoot 在配置中几乎没有任何作用。

标签: apache2virtualhostraspberry-pi3document-root

解决方案


It seems you created a new virtual host configuration file on this path /etc/apache2/sites-available/

you need to enable the website virtual host conf file, for example, id website virtual host conf file name is 'websitea.conf' then you need run below command

sudo a2ensite websitea.conf


推荐阅读