Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm struggling with getting Virtual Hosts running on my local Lion development machine.

Here's the scenario. I have Site-A.dev and Site-B.dev sitting in my User/computername/Sites folder, like this: User/computername/Sites/Site-A.com User/computername/Sites/Site-B.com

My /etc/apache2/extra/httpd-vhosts.conf file has the following entries:

#<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>

And my etc/hosts file looks like:

##
# 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

Eventhough all instances of Site-A are commented out, every time I try http://project.Site-B.dev I get Site-A in the browser! What in the world is going on?

To make matters more confounding, when edit my /etc/apache2/httpd.conf file to look like this:

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

I get a Server Not Found error!

If I leave it like:

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

Then all I get is Site-A

What am I missing?

Edit It should be noted that both sites are running PHP

share|improve this question
add comment

1 Answer

After running httpd -S I discovered that the location of my httpd-vhosts.conf file had been moved to /private/etc/apache2/other/httpd-vhosts.conf.

Heres what the httpd -S reported:

[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

Once I discovered that I was editing the wrong httpd-vhosts.conf file I was able to fix the problem.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.