python 2.7 django 1.9 apache 2.2 mod_wsgi部属网站
测试环境 win xp sp3 , apache 2.2 , python 2.7 , django 1.9django 1.9 文档
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/
wsgi 文档
http://modwsgi.readthedocs.org/en/develop/installation.html
下载win 版本 4.4.21
文档
https://github.com/GrahamDumpleton/mod_wsgi/tree/master/win32
下载
https://github.com/GrahamDumpleton/mod_wsgi/releases
只提供mod_wsgi 4.4.12 的 二进制下载,新版本要自己编译
https://github.com/GrahamDumpleton/mod_wsgi/releases/download/4.4.12/mod_wsgi-windows-4.4.12.tar.gz
解压后,只需要 Apache22-win32-VC9 中的 mod_wsgi-py27-VC9.so 文件 改名为 mod_wsgi.so 放到 apache 的 modules 里面。
安装 vc9 运行环境 就是 vc++ 2008 x86 run time
安装 apache2.2 后,修改 httpd.conf
添加一行
LoadModule wsgi_module modules/mod_wsgi.so
保存
重启
无报错说明配置成功
打开 支持多主机
Include conf/extra/httpd-vhosts.conf
WSGIPythonPath "d:/www/"
<VirtualHost *:80>
ServerAdmin admin@qingruxu.com
DocumentRoot "d:/www"
ServerName www.qingruxu.com
ServerAlias www.qingruxu.com
ErrorLog "logs/qingruxu.err.log"
CustomLog "logs/qingruxu.access.log" common
WSGIScriptAlias / "d:/www/www/wsgi.py" #只有 django 1.9 才会在生成和project 同名的文件夹
<Directory "d:/www">
Order allow,deny
Allow from all
</Directory>
Alias /static "d:/www/app/static" #发布的静态文件
#Alias /static "C:\Python27\Lib\site-packages\Django-1.9-py2.7.egg\django\contrib\admin\static"
#admin 自带后台管理的样式表
</VirtualHost>
如果把文件放到 项目根目录里面是无法直接通过 apache 访问到的。
需要通过 Alias 来添加指定以后才能访问。
以下是新建测试项目
cd d:
django-admin startproject www
cd www
django-admin startapp app
在 d:/www/www/settings.py 中加入 app
- 上一篇:django1.9 静态文件配置
- 下一篇:django1.9 静态文件配置iis6