虚拟主机打开另一个虚拟主机

时间:2014-08-04 11:11:44

标签: zend-framework2 virtualhost

主持人姓名:dhs

<VirtualHost *:80>
   DocumentRoot "/var/www/dhs/public/"
   ServerName dhs

   # This should be omitted in the production environment
   SetEnv APPLICATION_ENV development

   <Directory "/var/www/dhs/public/">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>

</VirtualHost>

主机名:deforay

<VirtualHost *:80>
   DocumentRoot "/var/www/deforay/public/"
   ServerName deforay

   # This should be omitted in the production environment
   SetEnv APPLICATION_ENV development

   <Directory "/var/www/deforay/public/">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>

</VirtualHost>

但是dhs(例如:dhs /)打开了deforay主机,我在zend框架2中使用,“deforay”主机工作正常但不是dhs ...我还在主机文件中添加了dhs

1 个答案:

答案 0 :(得分:1)

您的配置似乎有效,唯一可能出错的方法是您没有激活基于命名的虚拟主机。

将该工作插入vhost配置文件NameVirtualHost *:80(如果使用其他文件,请编辑端口)

确保您的host文件包含

127.0.0.1    dhs
127.0.0.1    deforay

并使用

访问浏览器中的网页
http://dhs
http://deforay