【发布时间】:2015-06-22 14:20:05
【问题描述】:
我正在尝试在 wamp 中创建多个虚拟主机,但是当我添加第二个虚拟主机时,它会显示 wamp 主页。
这是我的主机文件:
#localhost name resolution is handled within DNS itself.
#127.0.0.1 localhost
#::1 localhost
127.0.0.1 localhost
127.0.0.1 www.site1.com
127.0.0.1 www.aksharen.com
::localhost
::www.site1.com
::www.aksharen.com
这是我的 httpd-vhosts.conf 文件:
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:/websites/www.site1.com/public"
ServerName "www.site1.com"
<Directory C:/websites/www.site1.com>
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
SetEnv APPLICATION_ENV "development"
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:/websites/www.aksharen.com/public"
ServerName "www.aksharen.com"
<Directory C:/websites/www.aksharen.com>
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
SetEnv APPLICATION_ENV "development"
</VirtualHost>
我的第一个站点,即 www.site1.com 运行良好。
【问题讨论】:
-
@NishantSolanki — 如果您不想要多个虚拟主机,为什么还要虚拟主机?虚拟主机的全部意义在于在单个服务器上支持多个网站!
-
@Quentin 嘿抱歉,我误会了,我以为她想在本地电脑上创建虚拟服务器.. :P
-
@Vaidehi.. 你好,你有没有从你的
httpd.conf文件中取消注释Include conf/extra/httpd-vhosts.conf这一行?请参考此链接thegeekstuff.com/2011/07/apache-virtual-host -
您可以使用
httpd -S验证虚拟配置语法 -
请选择一个答案
标签: php apache wamp virtualhost