Server Fault is a question and answer site for system and network administrators. 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 running Ubuntu 10.04 with apache, rails, mysql, etc.

My rails site is running at I'm intending to use named-based virtual hosting and I have a virtual hosts file configured/enabled for My site is hosted on Amazon EC2.

The problem is that if I set up a new DNS record -- say -- and browse to that, my site is served up! That's without configuring any new virtual hosts.

And the same is true if I go to my DNS records and define, etc. Without touching my server, these new URLs serve up my website.

That's not what I want! I want to use name-based virtual hosting and host different sites for each subdomain.

Where could my problem be?

Here's my virtual hosts file:

ServerSignature Off
ServerTokens Prod
#NameVirtualHost *:80 - this is defined in a default config file already.

<VirtualHost *:80>
    UseCanonicalName On

    DocumentRoot /home/ubuntu/example/public
    ErrorLog /home/ubuntu/example/log/error.log

    <Directory /home/ubuntu/example/public/>
           AllowOverride all
           Options -MultiViews 

share|improve this question
up vote 2 down vote accepted

If there aren't any matching virtual hosts to use, apache will use what it considers to be the default virtual host. If you want a blank page to display, set that as the first virtual host, then define your entry afterwards.

share|improve this answer
thanks. So apparently my real problem is not what I thought it was. My real problem now appears to be that when I copy this virtual hosts file and edit it to add a new subdomain name, set up the corresponding site, etc., and enable the virtual host (a2ensite) and restart (graceful), apache immediately stops serving up any websites. Apparently apache crashes although I do not see any error messages. But all my sites go down and I have to revert and then restart apache. I thought this was because my virt host file (pasted above) had an error, but I don't see one. – MountainX Feb 18 '11 at 0:48
@MountaomX try the command apache2ctl -t before restarting, it will tell you if there are syntax errors in the configuration. – Fabio Feb 18 '11 at 0:52
OK, I went thru the steps, made a second site identical to the first, enabled it, checked with apache2ctl -t (response "Syntax OK"), ran /etc/init.d/apache2 graceful, and the first site went down (the 2nd never came up). I did a2dissite on the new virtual host and restarted apache and the first site came back up. – MountainX Feb 18 '11 at 0:58
I should probably start a new question and mark this one as answered. Unfortunately, I don't even know how to describe my problem now... – MountainX Feb 18 '11 at 1:07
Solved! Unbelievable... The problem was incorrect permissions on the log directory of the 2nd site. I never would have believed this would bring both sites down, so I was not looking for something like that. I was looking for something general to both sites. – MountainX Feb 18 '11 at 1:32

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.