我试图在我的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服务器并测试了URL,例如:
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
我在过去三四天里已经搜索了太多次,也阅读了一些关于如何在XAMPP上创建虚拟主机的帖子,例如how to create virtual host on XAMPP,但是没有成功。请告诉我我错过了什么。
谢谢