1.下载python-2.7.msi、Django-1.3.tar.gz
默认安装python2.7配置好python_home,安装django,解压运行python install
2.下载httpd-2.2.22-win32-x86-no_ssl.msi、mod_wsgi-win32-ap22py27-3.3.so
http://httpd.apache.org
http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-win32-ap22py27-3.3.so
默认安装apache、copy mod_wsgi-win32-ap22py27-3.3.so 到apache/modules下
Apache的httpd.conf文件中最后加入以下两行
LoadModule wsgi_module modules/mod_wsgi-win32-ap22py27-3.3.so
Include "D:/python/djangoProject/myFirstDjango/apache/apache_django_wsgi.conf"
其中myFirstDjango是在D:/python/djangoProject
创建的django项目,django-admin.py startproject myFirstDjango
在myFirstDjango目录下创建一个apache文件夹,添加下面2个文件:
apache_django_wsgi.conf和django.wsgi。
apache_django_wsgi.conf文件内容:
# 设置django admin静态资源的访问路径
Alias /static/ "D:/python/djangoProject/static/"
<Directory "D:/python/djangoProject/static">
Allow from all
</Directory>
# 设置root,不要使用"^/"
WSGIScriptAlias / "D:/python/djangoProject/myFirstDjango/apache/django.wsgi"
<Directory "D:/python/djangoProject/myFirstDjango/apache/">
Allow from all
</Directory>
django.wsgi内容:
import os
import sys
#Calculate the path based on the location of the WSGI script.
apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)