I am getting major problems getting Django dealing with my Apache configuration. I didn't produce the server, and so i do not have an excessive amount of leeway regarding the way the server works. Basically you will find three virtual hosts:

board.site.org, students.site.org and insider.site.org

The insider.site.org may be the primary one I am worried about. I am responsible for a little site beneath it (ideally at insider.site.org/tech). I made the decision to place my files outside of the initial directory, as to not chance playing up something inside (since a non-python website is already in position). Anyway, my virtual hosts are defined in separate files in /etc/apache2/vhosts.d/

This is what the insider.site.org's config appears like


LoadModule python_module /usr/lib64/apache2/mod_python.so

ServerName insider.site.org
DocumentRoot /media/nss/VWEB/docs
   <Directory /media/nss/VWEB/docs>
      Options Indexes Multiviews
      AllowOverride None
      Order Allow,Deny
      #Allow from
      Allow from all

Alias /tech  /srv/www/Tech

   <Directory /srv/www/Tech>
      SetHandler python-program
      PythonPath "['/srv/www/Tech'] + sys.path"
      PythonHandler django.core.handlers.modpython
      SetEnv DJANGO_SETTINGS_MODULE Tech.settings
      PythonDebug On

Alias /media /srv/www/Media

   <Directory /srv/www/Media>
      SetHandler None

  • Observe that when saying site.org, I am mentioning to my website, not the really "site.org" website.

Now, it appears like that needs to be to me, but for whatever reason, being able to access http://insider.site.org/tech/ provides me with this error:

Mod_python error: "PythonHandler mod_python.writer"

Traceback (newest call last):

File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req)

File "/usr/lib64/python2.4/site-packages/mod_python/writer.py", line 98, in handler path=[path])

File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 454, in import_module f, p, d = imp.find_module(parts[i], path)

ImportError: No module named index

Whereas http://insider.site.org/tech (no trailing forward slash) produces a 403 error. I actually do have Django within this directory, however it simply is not getting performed (I've _ init _.py in most my sites underneath the tech folder, which is a duplicate from the own pc (which went from the django test server)) and so i don't believe this is the problem. It is not working :-(

Any assistance is appreciated, thanks.

For the first problem, are you certain you've Django within the PythonPath you've specified? On my small server, their email list during my PythonPath includes your directory that contains the very best-level django directory, which itself consists of the bin, contrib, admin, core, etc. sites, additionally to __init__.py. (Also make certain your Apache user has read and execute permissions of these files and sites, although I am sure this really is apparent.) This really is my setup:

<Location "/myapp">
   SetHandler python-program
   PythonHandler django.core.handlers.modpython
   SetEnv DJANGO_SETTINGS_MODULE LogFileAnalyzer.settings
   PythonDebug on
   PythonPath "['/srv/www/dir_containing_django_dir', '/srv/www/myapp_dir'] + sys.path"

Observe that I am using Location rather than Directory here, so that your mileage can vary.

For the second problem, that seems like an issue for mod_rewrite. See here. You are able to allow the server append the slash you'll need instantly by determining a rewrite rule:

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^foo$  foo/  [R]

Hope that can help.