![为什么这个 VirtualDocumentRoot 设置返回 403 Access Forbidden?](https://linux22.com/image/632264/%E4%B8%BA%E4%BB%80%E4%B9%88%E8%BF%99%E4%B8%AA%20VirtualDocumentRoot%20%E8%AE%BE%E7%BD%AE%E8%BF%94%E5%9B%9E%20403%20Access%20Forbidden%EF%BC%9F.png)
httpd-vhosts.conf
我已经使用以下命令进行了设置:
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon
<VirtualHost 192.168.1.100:80>
VirtualDocumentRoot "E:/Web Development Projects/%3/%2.1/%2+"
DirectoryIndex index.php index.html index.htm default.html default.htm home.html default.php home.php
</VirtualHost>
<VirtualHost 192.168.1.100:443>
SSLEngine On
SSLCertificateFile "E:/Web Development Projects/SSL/apache.crt"
SSLCertificateKeyFile "E:/Web Development Projects/SSL/apache.key"
VirtualDocumentRoot "E:/Web Development Projects/%3/%2.1/%2+"
DirectoryIndex index.php index.html index.htm default.html default.htm home.html default.php home.php
</VirtualHost>
但不幸的是,我的本地网络服务器返回“403 禁止访问”消息。
请注意,相同的配置已安装在另一台机器上并且运行良好。
这个设置有什么问题吗?
有人可以帮帮我吗?
笔记:我的文件结构E:/Web Development Projects/tld/i/domain.tld/
如下
tld
是我的本地顶级域名 (dch)i
域名首字母是什么domain.tld
是项目域名
这使我拥有以下文件系统结构
E:\
Web Development Projects\
dch\
a\
a-project.dch\
Files
another-project.dch\
Files
\z
z-project.dch\
Files
更新 #1
我刚刚按照下面的说明操作,但 Apache 仍然无法启动。
以下是我的httpd-vhosts.conf
修改内容:
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon
<VirtualHost 192.168.1.100:80>
VirtualDocumentRoot "E:/Web Development Projects/%3/%2.1/%2+"
DirectoryIndex index.php index.html index.htm default.html default.htm home.html default.php home.php
<Directory "E:/Web Development Projects/">
Order deny, allow
Require all granted
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.100:443>
SSLEngine On
SSLCertificateFile "E:/Web Development Projects/SSL/apache.crt"
SSLCertificateKeyFile "E:/Web Development Projects/SSL/apache.key"
VirtualDocumentRoot "E:/Web Development Projects/%3/%2.1/%2+"
DirectoryIndex index.php index.html index.htm default.html default.htm home.html default.php home.php
</VirtualHost>
但这是服务器结果:
Error: Apache shutdown unexpectedly.
This may be due to a blocked port, missing dependencies,
improper privileges, a crash, or a shutdown by another method.
Press the Logs button to view error logs and check
the Windows Event Viewer for more clues
If you need more help, copy and post this
entire log window on the forums
还有更多信息吗?
答案1
尝试在 Virtualhost 配置中添加 acl,也许某些全局指令拒绝访问:
<Directory "E:/Web Development Projects/">
Order deny, allow
Require all granted
</Directory>
如果 apache 版本 <= 2.4,则将“Require all grant”替换为“Allow from all”。
希望能帮助到你。
答案2
为了其他人的利益,我也遇到了这个问题,我的解决方案不同:
1) 确保没有 .htaccess 或来自 httpd.conf (或类似文件) 的包含 conf 文件覆盖任何指令。注释掉所有include
指令以确保无误。
2) 您是否尝试从您的目录中提供内容/home
?不要。或者,如果必须,请设置chmod -R +x
您的主目录。