GeoDjango uses the GDAL geospatial library which is not thread safe at this time. Thus, it is highly recommended to not use threading when deploying – in other words, use an appropriate configuration of Apache or the prefork method when using FastCGI through another Web server.
In this section there are some example VirtualHost directives for when deploying using either mod_python or mod_wsgi. At this time, we recommend mod_wsgi, as it is now officially recommended way to deploy Django applications with Apache. Moreover, if mod_python is used, then a prefork version of Apache must also be used. As long as mod_wsgi is configured correctly, it does not matter whether the version of Apache is prefork or worker.
The Alias and Directory configurations in the examples below use an example path to a system-wide installation folder of Django. Substitute in an appropriate location, if necessary, as it may be different than the path on your system.
<VirtualHost *:80> WSGIDaemonProcess geodjango user=geo group=geo processes=5 threads=1 WSGIProcessGroup geodjango WSGIScriptAlias / /home/geo/geodjango/world.wsgi Alias /media/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/" <Directory "/usr/lib/python2.5/site-packages/django/contrib/admin/media/"> Order allow,deny Options Indexes Allow from all IndexOptions FancyIndexing </Directory> </VirtualHost>
If the WSGIDaemonProcess attribute threads is not set to 1, then Apache may crash when running your GeoDjango application. Increase the number of processes instead.
For more information, please consult Django’s mod_wsgi documentation.
Support for mod_python will be deprecated in a future release of Django. If you are configuring a new deployment, you are strongly encouraged to consider using mod_wsgi or any of the other supported servers.
<VirtualHost *:80> <Location "/"> SetHandler mod_python PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE world.settings PythonDebug On PythonPath "['/var/www/apps'] + sys.path" </Location> Alias /media/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/" <Location "/media"> SetHandler None </Location> </VirtualHost>
When using mod_python you must be using a prefork version of Apache, or else your GeoDjango application may crash Apache.
For more information, please consult Django’s mod_python documentation.
Having trouble? We'd like to help!
- Try the FAQ — it's got answers to many common questions.
- Search for information in the archives of the django-users mailing list, or post a question.
- Ask a question in the #django IRC channel, or search the IRC logs to see if it has been asked before.
- If you notice errors with this documentation, please open a ticket and let us know! Please only use the ticket tracker for criticisms and improvements on the docs. For tech support, use the resources above.