Ticket #9970: wsgi.txt

File wsgi.txt, 2.0 KB (added by Alex, 7 years ago)

first draft(should be good though), needs to be added to the index as well

Line 
1.. _howto-deployment-modwsgi:
2
3==========================================
4How to use Django with Apache and mod_wsgi
5==========================================
6
7Apache_ with `mod_wsgi`_ is one of the reccomended ways for using Django in
8production.
9
10.. _Apache: http://httpd.apache.org/
11.. _mod_wsgi: http://code.google.com/p/modwsgi/
12
13mod_wsgi is an Apache module which can be used to host any Python application
14which supports the Python WSGI interface (`PEP 333`_), including Django.  Django
15will work with any version of Apache which supports mod_wsgi.
16
17.. _PEP 333: http://www.python.org/dev/peps/pep-0333/
18
19Basic Configuration
20===================
21
22First make sure you have Apache installed, and mod_wsgi installed and activated. 
23Next edit your ``httpd.conf`` file and add::
24
25    WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi
26
27Where the first path is the url you want to be serving your application at (/
28indicates the root url), and the second is the location of a WSGI file (to be
29explained momentarily) on your system, usually inside of your project.  This
30will tell Apache to serve any request at that URL using WSGI, configured with
31that file.  Next we create our WSGI file, at the location we just indicated and
32put in it::
33
34    import os
35    import sys
36
37    os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
38
39    import django.core.handlers.wsgi
40    application = django.core.handlers.wsgi.WSGIHandler()
41
42If your project is not on your PYTHONPATH by default you can add::
43
44    sys.path.append('/usr/local/django')
45
46to place it on the path.  Also replace 'mysite.settings' with your settings file.
47
48See the :ref:`Apache/mod_python documentation<howto-deployment-modpython>` for
49directions on serving static media, and the `mod_wsgi documentation`_ for an
50explanation of other directives and configuration options you can use.
51
52.. _mod_wsgi documentation: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
Back to Top