Apr 28, 2009

Django with Apache and mod_wsgi on Windows XP

This is another tutorial that how did I transfer from using mod_python to mod_wsgi.
  1. Get mod_wsgi, you need to have correct version for your Apache and python, in my case, it is:
    mod_wsgi-2.3 - Apache 2.2 / Python 2.5
    Put the downloaded module into "C:\Program Files\Apache Software Foundation\Apache2.2\modules."
  2. Add following directive into Apache configureation file ("C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf"):
    LoadModule wsgi_module modules/mod_wsgi.so

    WSGIScriptAlias / "D:/django/mysite/apache/django.wsgi"

    <directory "D:/django/mysite">
    Order allow,deny
    Allow from all
    </directory>
    <directory "D:/django/mysite/apache>
    Order allow,deny
    Allow from all
    </directory>
  3. Create the file you specified at WSGIScriptAlias above with content:
    import os, sys

    sys.path.append('D:/django')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
  4. Open http://127.0.0.1.
It worked!
Congratulations on your first Django-powered page.

No comments:

Post a Comment