I am trying to set up apache2 and django to support two different sites, example.com and beta.example.com, from the same server. But requests for beta.example.com are going to example.com.
My apache configuration file includes:
NameVirtualHost *:80 Include /var/www/main/sites-enabled Include /var/www/beta/sites-enabled
For main/, sites-enabled holds one file, main, which is linked to sites/available/main. This includes:
<VirtualHost *:80> ServerName example.com DocumentRoot /home/mycode/main </VirtualHost> <Location "/"> [Django & Python stuff] SetEnv DJANGO_SETTINGS_MODULE main.settings </Location>
For beta/, sites-enabled has one file, beta, with a similar symlink.
<VirtualHost *:80> ServerName beta.example.com DocumentRoot /home/mycode/beta </VirtualHost> <Location "/beta.example.com/"> [Django & Python stuff] SetEnv DJANGO_SETTINGS_MODULE beta.settings </Location>
I have set up my DNS so beta.example.com is forwarded to example.com (I think; I'm weak on DNS). I do think requests for beta.example.com are hitting the http server as such, as the access logs show requests for image files in connetion with beta.example.com (I've configured so Apache, not Django, handles image files).
But the page I get at beta.example.com is the page I'd expect for example.com. And when I start the server, I'm warned that "NameVirtualHost *:80 has no VirtualHosts."
What might I be doing wrong here?
UPDATE This seems to be a DNS problem. The changes suggested work as required for requests inside the LAN (where the router has assigned the hostname beta.example.com the local IP address of the server) but not for requests outside the LAN. Review of the other_vhosts_access.log shows that inside LAN requests for beta.example.com are appearing as beta.example.com, while outside requests are appearing as example.com.
I missed this last night because I looked at the server behavior from outside the LAN, and didn't check the inside requests. Sorry.
I'll go look at the DNS arrangements. Thanks for the help.