Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#5837 closed (invalid)

Multiple Django Apps on single Apache2 server occasionally load incorrect URLS file

Reported by: dsteinkamp@… Owned by: nobody
Component: HTTP handling Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Malcolm Tredinnick)

This is a rather odd bug we've come across in development, but here is the gist of it:

THE SETUP:
Two completely separate projects, Hostbase and Cellbill, are attempting to run simultaneously on a shared Apache2 server.

Hostbase and all its supporting files live in /var/www/webapps/ihw.
Cellbill and all its supporting files live in /var/www/webapps/cellbill

Each project has its own separate configuration file in /etc/apache2/webapps.d/ that defines locations and directories as per http://www.djangoproject.com/documentation/modpython/; each project resides at http://webserver/projectname/ where projectname is Hostbase or Cellbill. Here is the Config file for Cellbill; Hostbase is nearly identical (save things that shouldn't affect this):

Alias /cellbill/site_media /var/www/webapps/cellbill/site_media
<Directory /var/www/webapps/cellbill/site_media/>
Options FollowSymLinks
AllowOverride none
order allow,deny
allow from all
</Directory>

Alias /cellbill/django_media /var/www/webapps/cellbill/lib/django/contrib/admin/media
<Directory /var/www/webapps/cellbill/lib/django/contrib/admin/media/>
Options FollowSymLinks
AllowOverride none
order allow,deny
allow from all
</Directory>

Alias /cellbill /var/www/webapps/cellbill

<Location "/cellbill/">  
order allow,deny
allow from all
SetHandler python-program
PythonDebug On
PythonPath "['/var/www/webapps/cellbill','/var/www/webapps/cellbill/lib'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE cellbill.settings
</Location>

#remove mod_python function from static media
<Location "/cellbill/site_media/">
SetHandler None
</Location>

<Location "/cellbill/django_media/">
SetHandler None
</Location>

THE PROBLEM:

The problem is that when someone goes to http://webserver/cellbill/, it will occasionally (typically not repeatedly, but sometimes) load the URL conf for Hostbase, and subsequently throw a 404 error (since none of my URLs match theirs) and vice versa with their project and my URL conf.

Anyone have any idea what might be going on? We are the only two people running Django projects currently, however more are likely to come to this server in the future. Naturally we would like to figure out what is going on before more projects are deployed.

Thanks!

Change History (3)

comment:1 by Derek Steinkamp <dsteinkamp@…>, 17 years ago

Sorry the httpd.conf formatting came out weird. If anyone needs it reformatted, let me know.

comment:2 by Karen Tracey <kmtracey@…>, 17 years ago

Resolution: invalid
Status: newclosed

It's a little hard to be sure with the screwy formatting, but I cannot see that you have followed this advice from the doc page you linked:

If you need to put two Django installations within the same VirtualHost, you’ll need to take a special precaution to ensure mod_python’s cache doesn’t mess things up. Use the PythonInterpreter directive to give different <Location> directives separate interpreters:

<VirtualHost *>
    ServerName www.example.com
    # ...
    <Location "/something">
        SetEnv DJANGO_SETTINGS_MODULE mysite.settings
        PythonInterpreter mysite
    </Location>

    <Location "/otherthing">
        SetEnv DJANGO_SETTINGS_MODULE mysite.other_settings
        PythonInterpreter mysite_other
    </Location>
</VirtualHost>

The values of PythonInterpreter don’t really matter, as long as they’re different between the two Location blocks.

comment:3 by Malcolm Tredinnick, 17 years ago

Description: modified (diff)

Fixed formatting.

Note: See TracTickets for help on using tickets.
Back to Top