I have gotten virtual hosts to work, but somehow this setup of mine is behaving strangely.
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost
ServerName x.com
WSGIPassAuthorization On
WSGIScriptAlias / /var/x/production/x.wsgi
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
<VirtualHost *>
ServerAdmin webmaster@localhost
ServerName staging.x.com
WSGIPassAuthorization On
WSGIScriptAlias / /var/x/testing/x.wsgi
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
This is the 'default' file in /etc/apache2/sites-available on my server.
I have two .wsgi files pointing to two copies of the same site, with changed settings files (mainly the database is changed from production to staging).
Somehow this setup doesn't work, though. When x.com is on top, both x.com and staging.x.com use the same database. When I reverse the order, both domains point at the staging django project.
I'm pretty sure that this is not a bug in mod_wsgi, but maybe I'm using WSGIScriptAlias incorrectly, maybe I don't use apache's ServerName correctly.
Thanks for checking this out, I'm stumped!
EDIT: Here is the output of apache2 -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:* is a NameVirtualHost
default server x.com (/etc/apache2/sites-enabled/000-default:3)
port * namevhost x.com (/etc/apache2/sites-enabled/000-default:3)
port * namevhost staging.x.com (/etc/apache2/sites-enabled/000-default:19)
Syntax OK
Does that help? Sorry, very noob to the serverfault side of things. (Usually doing stackoverflow type work.)