title: Rails 3 Two Applications on Different Domains (same ip) with Apache?
body: <p>I deployed using phusion passenger on apache2 intially with just my single Rails application onto a domain, say <code>bar.com</code>. Now I wish to push an additional app I recently created to a subdomain on the bar domain, say <code>foo.bar.com</code>. I was a little confused about how I should setup the virtualhosts in the <code>httpd.conf</code> file to allow for this setup. I setup my DNS through godaddy so that the new subdomain would point to the same ip address as the initial domain (they're both residing on the same server). </p>
  
  <p>Here's the VirtualHosts in my httpd.conf file (notice the two document roots points to different applications):</p>
  
  <pre><code>NameVirtualHost *:80
  &lt;VirtualHost *:80&gt;
    ServerName bar.com
    ServerAlias www.bar.com
    DocumentRoot /home/me/app1/public
    &lt;Directory /home/me/app1/public&gt;
      AllowOverride all
      Options -MultiViews
    &lt;/Directory&gt;
  &lt;/VirtualHost&gt;  
  
  &lt;VirtualHost *:80&gt;
    ServerName foo.bar.com
    ServerAlias foo.bar.com www.foo.bar.com
    DocumentRoot /home/me/app2/public
    &lt;Directory /home/me/app2/public&gt;
      AllowOverride all
      Options -MultiViews
    &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>With this setup I can navigate to <code>www.bar.com</code> or <code>bar.com</code> but it seems the subdomain doesn't work, navigating to <code>foo.bar.com</code> leads me to this page:</p>
  
  <blockquote>
    <h2><strong>Not Found</strong></h2>
    
    <p>The requested URL / was not found on this server. </p>
    
    <p>Apache/2.2.20 (Ubuntu) Server at foo.bar.com Port 80</p>
  </blockquote>