From 58298fae71f59e3c2b3be40feda57f2b19690045 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Tue, 31 Mar 2009 19:34:25 +0000 Subject: [PATCH] Fixed #9970: added mod_wsgi docs. Thanks, Alex Gaynor. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10280 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/howto/deployment/index.txt | 14 ++----- docs/howto/deployment/modwsgi.txt | 68 +++++++++++++++++++++++++++++++ docs/index.txt | 2 +- 3 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 docs/howto/deployment/modwsgi.txt diff --git a/docs/howto/deployment/index.txt b/docs/howto/deployment/index.txt index 80c16fcd821..31efa14b299 100644 --- a/docs/howto/deployment/index.txt +++ b/docs/howto/deployment/index.txt @@ -11,23 +11,17 @@ ways to easily deploy Django: .. toctree:: :maxdepth: 1 + modwsgi modpython fastcgi -:ref:`Deploying under mod_python ` 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 ` 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: http://djangobook.com/en/1.0/chapter20/ -.. _mod_wsgi: http://code.google.com/p/modwsgi/ -.. _use mod_wsgi with Django: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango \ No newline at end of file diff --git a/docs/howto/deployment/modwsgi.txt b/docs/howto/deployment/modwsgi.txt new file mode 100644 index 00000000000..fa1d39cc823 --- /dev/null +++ b/docs/howto/deployment/modwsgi.txt @@ -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: http://httpd.apache.org/ +.. _mod_wsgi: http://code.google.com/p/modwsgi/ + +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: http://www.python.org/dev/peps/pep-0333/ + +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: http://code.google.com/p/modwsgi/ +.. _installation and configuration documentation: http://code.google.com/p/modwsgi/wiki/InstallationInstructions + +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` for +directions on serving static media, and the `mod_wsgi documentation`_ for an +explanation of other directives and configuration options you can use. + +Details +======= + +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: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango \ No newline at end of file diff --git a/docs/index.txt b/docs/index.txt index 715057d4f78..5ed85d755e0 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -73,7 +73,7 @@ The development process * **Settings:** :ref:`Overview ` | :ref:`Full list of settings ` * **django-admin.py and manage.py:** :ref:`Overview ` | :ref:`Adding custom commands ` * **Testing:** :ref:`Overview ` - * **Deployment:** :ref:`Overview ` | :ref:`Apache/mod_python ` | :ref:`FastCGI/SCGI/AJP ` | :ref:`Apache authentication ` | :ref:`Serving static files ` | :ref:`Tracking code errors by e-mail ` + * **Deployment:** :ref:`Overview ` | :ref:`Apache/mod_wsgi ` | | :ref:`Apache/mod_python ` :ref:`FastCGI/SCGI/AJP ` | :ref:`Apache authentication ` | :ref:`Serving static files ` | :ref:`Tracking code errors by e-mail ` Other batteries included ========================