Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to set up two virtual hosts. Here's my httpd config:

<Directory /Users/userX/dev/sandbox-2>
    Order deny,allow
    deny from All
    Allow from localhost
</Directory>

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
    DocumentRoot "/Users/userX/dev/sandbox-2"
    ServerName blah                                                        
</VirtualHost>                     

<VirtualHost 127.0.0.1> 
    DocumentRoot "/Users/userX/dev/sandbox"
    ServerName fooboar
</VirtualHost>

My problem is that, no matter which server name I try to access in my browser (blah or foobar) it'll serve from blah's DocumentRoot. However, if I were to comment out the the VirtualHost for blah, then it'll take me to foobar's DocumentRoot.

share|improve this question
    
I haven't seen vhosts done that way, could you try changing the three instances of 127.0.0.1 to 127.0.0.1:80 to make sure it matches? –  Paul May 25 '12 at 3:20
    
Thanks. You're right but there were actually multiple mistakes with my config. Solution posted at the bottom. –  Glide May 25 '12 at 8:56

1 Answer 1

There are multiple issues..

The biggest one is that I had a typo. (I had fooboar, not foobar)

Second, I need to include the port in NameVirtualHost as well as in

Also, what helped a lot while debugging this was start httpd in debug mode which is:

apachectl -e debug
share|improve this answer

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.