Entries tagged with mod_python rss

apache2/mod_python configuration for django

The request for a working apache/mod_python configuration example comes up frequently on the django IRC channel. Usually a bad configuration is the underlying problem when admin media doesn't show up or when projects are not found on the python path. This is the model I use:

<VirtualHost xxx.xxx.xxx.xxx> ServerAdmin admin@example.com DocumentRoot /home/username/projectname/public_html/ ServerName example.com CustomLog /var/log/apache2/access.log combined Alias /adminmedia /usr/share/python-support/python-django/django/contrib/admin/media Alias /media /home/username/projectname/media <Location "/"> SetHandler python-program PythonHandler django.core.handlers.modpython PythonPath "['/home/username/projectname/projects/'] + sys.path" SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonDebug On </Location> <Location "/media"> SetHandler None </Location> <Location "/adminmedia"> SetHandler None </Location> </VirtualHost>

This is for a directory layout like this:

/home/username/projectname/ <- your project directory /home/username/projectname/media/ <- media /home/username/projectname/public_html/ <- empty, a harmless place to point apache /home/username/projectname/projects/ <- where all your projects live /home/username/projectname/projects/mysite/ <- your main project/app

Inside mysite/, you have settings.py. In settings.py, you've set MEDIA_ROOT = '/home/username/projectname/media/' and MEDIA_URL = '/media/' and ADMIN_MEDIA_PREFIX = '/adminmedia/'.