- Get following files, but notice there're some limitations for the combination. For instance, mod_python does not recognize Python26 or later version.
- apache_2.2.11-win32-x86-no_ssl.msi
- python-2.5.4.msi
- Django-1.0.2-final.tar.gz
- mod_python-3.3.1.win32-py2.5-Apache2.2.exe
- Install Apache (C:\Program Files\Apache Software Foundation\Apache2.2), I chose "Install Apache for All Users, on Port 80, as a Service."
- Install Python (C:\Python25), I chose "Install for all users."
- Update system environment with path "C:\Python25" included.
- Install mod_python, it will ask where do you put your Python and Apache.
- Add this line into Apache configuration (...\Apache2.2\httpd.conf) to load mod_python:
LoadModule python_module modules/mod_python.so
- Install Django, untar the archive and run command "python setup.py install" from command prompt, it will be installed at "C:\Python25\Lib\site-packages\django."
- Create a directory for storing Django projects (D:\django).
- Create a Django project (mysite) by running command "C:\Python25\Scripts\django-admin.py startproject mysite." A new directory "D:\django\mysite" will then be created.
- Put this directive into Apache configuration file:
<location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonPath "['D:/django'] + sys.path"
PythonDebug On
</location> - Open http://127.0.0.1/.
Congratulations on your first Django-powered page.
Notes
- DJANGO_SETTINGS_MODULE xxx.settings, xxx is the project's name created at step 9.
- If the url you want for your project is something like "http://127.0.0.1/best/*", you need to use
<location "/best/">
at step 10 instead.
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /best
PythonPath "['D:/django'] + sys.path"
PythonDebug On
</location>
No comments:
Post a Comment