我尝试在我的Windows 10,64位XAMPP 3.2.1上创建多个虚拟主机 我做了以下事情:
1- C:\ Windows \ System32 \ drivers \ etc \ hosts
我在hosts文件的底部添加了这些行:
127.0.0.1 smc
127.0.0.1 ocms
2- D:\ xampp \ apache \ conf \ httpd.conf
虚拟主机已启用,请参阅以下内容:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
3- D:\ xampp \ apache \ conf \ extra \ httpd-vhosts.conf
这里我在httpd-vhosts.conf文件中添加了以下代码块:
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName smc
DocumentRoot "D:/vhosts/smc"
SetEnv APPLICATION_ENV "development"
<Directory "D:/vhosts/smc/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName ocms
DocumentRoot "D:/vhosts/ocms/"
SetEnv APPLICATION_ENV "development"
<Directory "D:/vhosts/ocms">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
最后我把我的目录放在我的D:/ vhosts /文件夹中:
D:/vhosts/ocms
D:/vhosts/smc
在我重新启动我的apache服务器并测试网址之后:
http://ocms
或
http://smc
它返回以下错误:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
ocms
Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8
我在过去的三到四天里用Google搜索了太多次,并且还关注了stackoverflow上的其他帖子,即how to create virtual host on XAMPP,但没有运气。请让我知道我错过了什么。 感谢
答案 0 :(得分:0)
好的,我已经做到了。我必须将所有目录放在htdocs文件夹下。 结构应该是:
D:\xampp\htdocs
D:\xampp\htdocs\test\smc
D:\xampp\htdocs\test\ocms
感谢大家的宝贵时间
答案 1 :(得分:0)
您的初始设置对我来说很好。
我认为你的问题是索引丢失了。
此行将强制Apache仅接受 index.php 文件作为入口点:
DirectoryIndex index.php
但是,如果您的入口点有不同的名称或扩展名,则会收到错误:
You don't have permission to access the requested directory. There is either no index document or the directory is read-protecte