Sunday, May 27, 2007

How to setup Django with Apache.

1. Ensure Apache / Mod_python is working by following the link below:
http://www.djangoproject.com/documentation/modpython/

2. Install djano

3. Config apache:
Suppose, the document root is "/home/httpd/html", the Django site is in "/home/httpd/html/django",
add the following section into apache's config file (for arch linux: /etc/httpd/conf/httpd.conf)

SetHandler python-program
PythonPath "['/home/httpd/html/'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE django.settings
PythonDebug On


4. Finally, restart apache (/etc/rc.d/httpd restart)
5. check if it is working by visiting localhost/django
"It Worked" will show up if it is successful.

No comments: