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.
I own 2 domains that I'm trying to host on a single server. Call them www.my_first_domain.com and www.my_second_domain.com.
Now, I have more than 3 Django projects I'm going to be hosting. One project will be pointed to www.my_first_domain.com. One project will be pointed to www.my_second_domain.com. All other projects will be pointed to subdomains of www.my_second_domain.com.
i.e. project3.my_second_domain.com, project4.my_second_domain.com, etc.
I've managed the DNS to have all these point to the correct IP. I've verified this with `host www.my_first_domain.com, host www.my_second_domain.com, host project3.my_second_domain.com, etc. They all point to the correct IP.
Below are 3 examples of the files I've setup to try and get this to work.
/etc/apache2/sites-enabled/project1
<VirtualHost *:80>
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
<Directory /home/user1/website/project1/project1>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
</VirtualHost>
/etc/apache2/sites-enabled/project2
<VirtualHost *:80>
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
<Directory /home/user2/website/project2/project2>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
</VirtualHost>
/etc/apache2/sites-enabled/project3
<VirtualHost *:80>
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
<Directory /home/user3/website/project3/project3>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
</VirtualHost>
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 Internal Server Error.
If I look at the error log for project3 it looks like it's trying to load the Django settings for project1.
I purposefully emptied /etc/apache2/httpd.conf as I was under the impression that the sites-enabled files will be used in place of httpd.conf when using virtual hosts the way I am.
I don't believe I've modified any other configuration files. Any ideas as to what I've done wrong?
a2ensiteon each of your configurations, correct? 2) Make sure your Python paths are correct in your wsgi.py scripts. Hope that helps. EDIT: Make sure your confs are insites-availableand then runa2ensitedon't just create the files insites-enabled.a2ensitethen edited them to have the virtual host info. I've also double checked the Python paths in the wsgi.py scripts -sys.path.append('/home/user3/website/project3'), etc. Also, the conf files are also insites-availableas they are just symbolic links.sites-enabledand the raw files were undersites-available. I've done exactly what you're asking without any issues, so I'll double check my server when I get home. In the meantime, double check my thoughts on the raw files supposed to be insites-available.a2ensite. See my solution below for copies of my conf files as well as my wsgi files.