win7+Apache2.2+python2.7+Django1.4+mod_wsgi.so环境搭建

Django1.4的wsgi设置有所改变

主要参考https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/
1.安装httpd-2.2.21-win32-x86-no_ssl.msi
2.下载mod_wsgi-win32-ap22py27-3.3.so (http://code.google.com/p/modwsgi/downloads/list)
3.将mod_wsgi.so F:\Apache2.2\modules中,然后再httpd.conf中添加LoadModule wsgi_module modules/mod_wsgi.so
4.然后再httpd.conf末尾添加
WSGIScriptAlias / "E:/Py_workspace/Py_test1/src/0709/Django_test/mysite/mysite/wsgi.py"(wsgi.py在项目中的路径)
WSGIPythonPath "E:/Py_workspace/Py_test1/src/0709/Django_test/mysite"(项目路径)

<Directory "E:/Py_workspace/Py_test1/src/0709/Django_test/mysite/mysite">
<Files wsgi.py>
Order allow,deny
Allow from all
</Files>
</Directory>
5.项目静态文件的访问配置:
如果要访问Django admin的static文件可以将C:\Python27\Lib\site-packages\django\contrib\admin\static下的admin拷贝到自己项目中的static文件夹下
如E:\Py_workspace\Py_test1\src\0709\Django_test\mysite,项目本身的所需资源也放在这里。
然后再settings.py设置STATIC_ROOT为项目static文件夹的路径,如E:\Py_workspace\Py_test1\src\0709\Django_test\mysite\static
最后在httpd.conf中添加如下设置
Alias /static/ "E:/Py_workspace/Py_test1/src/0709/Django_test/mysite/static/"

<Directory "E:/Py_workspace/Py_test1/src/0709/Django_test/mysite/static">
Order deny,allow
Allow from all
</Directory>
6.重启Apache

posted @ 2012-09-05 00:03  Aveen  阅读(1147)  评论(0编辑  收藏  举报
Top