apache2 - 更改 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-data:www-data
- 将烫发更改为 755/777
- 将目录配置放入
- apache2.conf 或网站的 conf 将所有网站放在 1 个文件中
- 各种目录设置(Options Indexes FollowSymLinks、AllowOverride none/all、Require all granted、Allow from all、Order Allow、Deny)
但没有一个会工作......
编辑:我发现该网站进入 /www/var/html/ 即使域设置为进入 /www/var/html/weba,但 DocumentRoot 在配置中几乎没有任何作用。
解决方案
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
推荐阅读
- python - 如何使用 PIL 优化调色板图像大小?
- python - pandas 根据前缀重塑 long
- objective-c - 通过Objective C中的lat long列表确定提供的lat long是否在区域中
- swift - 如何使用 UIView 单元格中的 firebase 用户名重命名不同视图控制器中的按钮?
- winforms - 创建基于.net core 3的WinForm项目
- .net - 直接访问 S3 Glacier Deep Archive
- bash - AOSP 构建日志中的这个 clang 命令中的 @ 是什么意思?
- selenium - 如何查找在页面上出现多次的类元素的 XPath?
- java - 如何使用 java 在 selenium 中执行静态等待?
- java - 解析具有可能作为字符串或字符串数组的属性的 json