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 have a virtual host configured to run a Ruby on Rails app on Apache and Passenger this way:

 <VirtualHost *:80>

  ServerAlias *
  DocumentRoot /home/ubuntu/staging/current/public

So,, are working find, this is for staging environment. Now I need to add the production environment on the same server. I wold like to add the production environment but I am not sure how to do it. The VPS is running on EC2. Even by using two different servers, there is the issue of the DNS server resolving all subdomains to the current VPS IP. I think the only solution is to use different second level domains:



What do you think?

share|improve this question
up vote 1 down vote accepted

If you are using name-based virtualhosts in apache, DNS has little to do with it; a million hostnames could end up at your IP and apache would still be able to serve a million distinct web sites.

That said, the problem with your setup is the line

ServerAlias *

You want to remove that and replace it with the actual subdomains in use for staging and/or production.

Also note that the first-listed virtualhost is by definition the default one in apache.

share|improve this answer
I am using ServerAlias * because the subdomain is created dynamically by the app (multi tennant app). – rtacconi Feb 27 '12 at 16:30
That's entirely irrelevant; it's horribly bad setup and there are at least 2 better alternatives. – adaptr Apr 18 '12 at 15:04

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.