代码改变世界

apache配置虚拟主机,为什么总是第一个VirtualHost起效 apache基于域名虚拟主机,只访问第一个的问题

2012-07-27 11:31  java环境变量  阅读(399)  评论(0编辑  收藏  举报

起初如下配置

<VirtualHost *:80>

......

........

..........
</VirtualHost>

 

<VirtualHost *:80>

......

........

..........
</VirtualHost>

但从第二个起,每个主机只访问第一个的主机内容。后来才发现文件最前面漏了:NameVirtualHost *,新的配置如下:

NameVirtualHost *

<VirtualHost *:80>

......

........

..........
</VirtualHost>

 

<VirtualHost *:80>

......

........

..........
</VirtualHost>

问题解决

 

 

#配置我们自己的虚拟主机
NameVirtualHost *
<VirtualHost *:80>
   DocumentRoot "F:/xampp/htdocs/zendfrm/public"
   ServerName harry.com
   DirectoryIndex  index.php  http://harry.com/index.php
   # This should be omitted in the production environment
   SetEnv APPLICATION_ENV development

   <Directory "F:/xampp/htdocs/zendfrm/public">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>

</VirtualHost>


#配置我们自己的虚拟主机
NameVirtualHost *
<VirtualHost *:80>
   DocumentRoot "F:/xampp/htdocs/htaccess_test/public"
   ServerName test100.com
   DirectoryIndex  index.php 
   # This should be omitted in the production environment
   SetEnv APPLICATION_ENV development

   <Directory "F:/xampp/htdocs/htaccess_test/public">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>

</VirtualHost>


#投票系统
NameVirtualHost *
<VirtualHost *:80>
   DocumentRoot "F:/xampp/htdocs/myvote/public"
   ServerName myvote100.com
 
   # This should be omitted in the production environment
 

   <Directory />
       Options  FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all
   </Directory>

</VirtualHost>