Browse files

[1.0.X] Fixed #9970: added mod_wsgi docs. Thanks, Alex Gaynor. Backpo…

…rt of r10280 from trunk.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
jacobian committed Mar 31, 2009
1 parent 377cc9c commit 6b937c67eae12e21d128d609fe0eceb28bb0f52a
Showing with 72 additions and 10 deletions.
  1. +4 −10 docs/howto/deployment/index.txt
  2. +68 −0 docs/howto/deployment/modwsgi.txt
@@ -11,23 +11,17 @@ ways to easily deploy Django:
.. toctree::
:maxdepth: 1
+ modwsgi
-:ref:`Deploying under mod_python <howto-deployment-modpython>` is the
-recommended deployment method; start there if you're not sure which path you'd
-like to go down.
+If you're new to deploying Django and/or Python, we'd recommend you try
+:ref:`mod_wsgi <howto-deployment-modwsgi>` first. In most cases it'll be the easiest,
+fastest, and most stable deployment choice.
.. seealso::
* `Chapter 20 of The Django Book`_ discusses deployment and especially
scaling in more detail.
- * `mod_wsgi`_ is a newcomer to the Python deployment world, but it's rapidly
- gaining traction. Currently there's a few hoops you have to jump through to
- `use mod_wsgi with Django`_, but mod_wsgi tends to get rave reviews from
- those who use it.
.. _chapter 20 of the django book:
-.. _mod_wsgi:
-.. _use mod_wsgi with Django:
@@ -0,0 +1,68 @@
+.. _howto-deployment-modwsgi:
+How to use Django with Apache and mod_wsgi
+Deploying Django with Apache_ and `mod_wsgi`_ is the recommended way to get
+Django into production.
+.. _Apache:
+.. _mod_wsgi:
+mod_wsgi is an Apache module which can be used to host any Python application
+which supports the `Python WSGI interface`_, including Django. Django will work
+with any version of Apache which supports mod_wsgi.
+.. _python wsgi interface:
+The `official mod_wsgi documentation`_ is fantastic; it's your source for all
+the details about how to use mod_wsgi. You'll probably want to start with the
+`installation and configuration documentation`_.
+.. _official mod_wsgi documentation:
+.. _installation and configuration documentation:
+Basic Configuration
+Once you've got mod_wsgi installed and activated, edit your ``httpd.conf`` file
+and add::
+ WSGIScriptAlias / /path/to/mysite/apache/django.wsgi
+The first bit aboveis the url you want to be serving your application at (``/``
+indicates the root url), and the second is the location of a "WSGI file" -- see
+below -- on your system, usually inside of your project. This tells Apache
+to serve any request below the given URL using the WSGI application defined by that file.
+Next we'll need to actually create this WSGI application, so create the file
+mentioned in the second part of ``WSGIScriptAlias`` and add::
+ import os
+ import sys
+ os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
+ import django.core.handlers.wsgi
+ application = django.core.handlers.wsgi.WSGIHandler()
+If your project is not on your ``PYTHONPATH`` by default you can add::
+ sys.path.append('/usr/local/django')
+just above the ``import`` line to place your project on the path. Remember to
+replace 'mysite.settings' with your correct settings file.
+See the :ref:`Apache/mod_python documentation<howto-deployment-modpython>` for
+directions on serving static media, and the `mod_wsgi documentation`_ for an
+explanation of other directives and configuration options you can use.
+For more details, see the `mod_wsgi documentation`_, which explains the above in
+more detail, and walks through all the various options you've got when deploying
+under mod_wsgi.
+.. _mod_wsgi documentation:

0 comments on commit 6b937c6

Please sign in to comment.