Lion 上的 VirtualHost 导航到错误的文档根目录

Lion 上的 VirtualHost 导航到错误的文档根目录

我正在努力让虚拟主机在我的本地 Lion 开发机器上运行。

场景如下。我的文件夹中有 Site-A.dev 和 Site-B.dev User/computername/Sites,如下所示: User/computername/Sites/Site-A.com User/computername/Sites/Site-B.com

我的/etc/apache2/extra/httpd-vhosts.conf文件有以下条目:

#<VirtualHost *:80>
#       DocumentRoot /Users/computername/Sites/Site-A.com
#       ServerName project.Site-A.dev
#</VirtualHost>
<VirtualHost *:80>
        DocumentRoot /Users/computername/Sites/Site-B.com
        ServerName project.Site-B.dev
</VirtualHost>

我的etc/hosts文件如下所示:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

#127.0.0.1      project.Site-A.dev
127.0.0.1       project.Site-B.dev

尽管 Site-A 的所有实例都被注释掉了,但每次我尝试时http://project.Site-B.dev都会在浏览器中获得 Site-A!到底发生什么事了?

更令人困惑的是,当我编辑我的/etc/apache2/httpd.conf文件时,它看起来像这样:

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

我收到“未找到服务器”错误!

如果我把它保留如下:

# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf

然后我得到的只是 Site-A

我错过了什么?

编辑需要注意的是,两个网站都运行 PHP

答案1

运行后httpd -S发现我的httpd-vhosts.conf文件的位置已经被移动到了/private/etc/apache2/other/httpd-vhosts.conf

报道内容如下httpd -S

[Tue Feb 07 12:51:37 2012] [warn] module php5_module is already loaded, skipping
httpd: Could not reliably determine the server's fully qualified domain name, using macshortname.local for ServerName
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server Site-A.com (/private/etc/apache2/other/httpd-vhosts.conf:17)
         port 80 namevhost Site-A.com (/private/etc/apache2/other/httpd-vhosts.conf:17)
         port 80 namevhost localhost (/private/etc/apache2/other/httpd-vhosts.conf:36)
Syntax OK

一旦我发现我编辑了错误的httpd-vhosts.conf文件,我就能解决问题。

相关内容