Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


    DocumentRoot "/Users/userX/dev/sandbox-2"
    ServerName blah                                                        

    DocumentRoot "/Users/userX/dev/sandbox"
    ServerName fooboar

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

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


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.