title: Apache2 Setup Virtual Hosts with Subdomains using Django Projects
body: <p>I'm using Django 1.4 with Python 2.7 on Ubuntu Server 12.04.  I'm trying to host multiple websites on a single server.  I'm new to Apache and seem to have written something incorrectly  when setting up virtual hosts.</p>
  
  <p>I own 2 domains that I'm trying to host on a single server.  Call them <code>www.my_first_domain.com</code> and <code>www.my_second_domain.com</code>.</p>
  
  <p>Now, I have more than 3 Django projects I'm going to be hosting.  One project will be pointed to <code>www.my_first_domain.com</code>.  One project will be pointed to <code>www.my_second_domain.com</code>.  All other projects will be pointed to subdomains of <code>www.my_second_domain.com</code>.</p>
  
  <p>i.e. <code>project3.my_second_domain.com</code>, <code>project4.my_second_domain.com</code>, etc.</p>
  
  <p>I've managed the DNS to have all these point to the correct IP.  I've verified this with <code>`host www.my_first_domain.com</code>, <code>host www.my_second_domain.com</code>, <code>host project3.my_second_domain.com</code>, etc.  They all point to the correct IP.</p>
  
  <p>Below are 3 examples of the files I've setup to try and get this to work.</p>
  
  <p><code>/etc/apache2/sites-enabled/project1</code></p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
          ServerName www.my_first_domain.com
          ServerAlias *.my_first_domain.com my_first_domain.com
          DocumentRoot /var/www/project1
  
          CustomLog /var/log/apache2/www.my_first_domain.com-access.log combined
          ErrorLog /var/log/apache2/www.my_first_domain.com-error.log
  
          WSGIScriptAlias / /home/user1/website/project1/project1/wsgi.py
  
          &lt;Directory /home/user1/website/project1/project1&gt;
                  &lt;Files wsgi.py&gt;
                          Order deny,allow
                          Allow from all
                  &lt;/Files&gt;
          &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><code>/etc/apache2/sites-enabled/project2</code></p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
          ServerName www.my_second_domain.com
          ServerAlias my_second_domain.com
          DocumentRoot /var/www/project2
  
          CustomLog /var/log/apache2/www.my_second_domain.com-access.log combined
          ErrorLog /var/log/apache2/www.my_second_domain.com-error.log
  
          WSGIScriptAlias / /home/user2/website/project2/project2/wsgi.py
  
          &lt;Directory /home/user2/website/project2/project2&gt;
                  &lt;Files wsgi.py&gt;
                          Order deny,allow
                          Allow from all
                  &lt;/Files&gt;
          &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><code>/etc/apache2/sites-enabled/project3</code></p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
          ServerName project3.my_second_domain.com
          DocumentRoot /var/www/project3
  
          CustomLog /var/log/apache2/project3.my_second_domain.com-access.log combined
          ErrorLog /var/log/apache2/project3.my_second_domain.com-error.log
  
          WSGIScriptAlias / /home/user3/website/project3/project3/wsgi.py
  
          &lt;Directory /home/user3/website/project3/project3&gt;
                  &lt;Files wsgi.py&gt;
                          Order deny,allow
                          Allow from all
                  &lt;/Files&gt;
          &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>If I go to www.my_first_domain.com everything looks correct.  When I go to www.my_second_domain.com I see what is at www.my_first_domain.com (my first project, not my second project).  If I go to project3.my_second_domain.com I get an <code>Internal Server Error</code>.</p>
  
  <p>If I look at the error log for project3 it looks like it's trying to load the Django settings for project1.</p>
  
  <p>I purposefully emptied <code>/etc/apache2/httpd.conf</code> as I was under the impression that the <code>sites-enabled</code> files will be used in place of <code>httpd.conf</code> when using virtual hosts the way I am.</p>
  
  <p>I don't believe I've modified any other configuration files.  Any ideas as to what I've done wrong?</p>