Opened 12 years ago

Closed 12 years ago

Last modified 12 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: master
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:

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; 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

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

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

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

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


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.


Change History (3)

comment:1 Changed 12 years ago by Derek Steinkamp <dsteinkamp@…>

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

comment:2 Changed 12 years ago by Karen Tracey <kmtracey@…>

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 *>
    # ...
    <Location "/something">
        SetEnv DJANGO_SETTINGS_MODULE mysite.settings
        PythonInterpreter mysite

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

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

comment:3 Changed 12 years ago by Malcolm Tredinnick

Description: modified (diff)

Fixed formatting.

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