Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to set up apache2 and django to support two different sites, and, from the same server. But requests for are going to

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>
    DocumentRoot /home/mycode/main

<Location "/">
    [Django & Python stuff]
    SetEnv DJANGO_SETTINGS_MODULE main.settings

For beta/, sites-enabled has one file, beta, with a similar symlink.

<VirtualHost *:80>
    DocumentRoot /home/mycode/beta

<Location "/">
    [Django & Python stuff]
    SetEnv DJANGO_SETTINGS_MODULE beta.settings

I have set up my DNS so is forwarded to (I think; I'm weak on DNS). I do think requests for are hitting the http server as such, as the access logs show requests for image files in connetion with (I've configured so Apache, not Django, handles image files).

But the page I get at is the page I'd expect for 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 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 are appearing as, while outside requests are appearing as

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.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I am not sure this is precisely your problem but NameVirtualHost does not have a colon. Also, the "Location" for the beta site is incorrect. Put your Location tag in both cases inside the VirtualHost container and stick to "/" in both cases.

share|improve this answer
Thx. That colon was a typo in the post, it isn't present in the configuration file. I moved the close of the Virtual Host blocks to enclose the Location blocks, and changed the beta Location to "/", but this didn't fix the problem. – chernevik Jun 25 '09 at 23:13
OK. Could you post some logs? But even before that - isolate the problem - so start by making sure the two virtual hosts actually work without django - just a simple static page. I suspect once you solve this bit the rest will go smoothly – mfx Jun 26 '09 at 8:55
See above. Your edits seem to have worked, it's a DNS problem. – chernevik Jun 26 '09 at 16:52
Having '<Location />' inside of 'VirtualHost' is redundant as that is the default context anyway. – Graham Dumpleton Jun 27 '09 at 11:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.