Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > Python网站web

windows 10下安装搭建django1.10.3和Apache2.4的方法

来源:中文源码网    浏览:180 次    日期:2024-04-29 08:51:06
【下载文档:  windows 10下安装搭建django1.10.3和Apache2.4的方法.txt 】


windows 10下安装搭建django1.10.3和Apache2.4的方法
环境介绍
python3.5.2 64位
django 1.10.3
apache 2.4 64位
windows 10
重点在apache上。
python 和django 相信有兴趣看这篇文章的基本上也都已经了解了。
安装Apache2.4
地址:http://www.apachelounge.com/download/
下载:vc_redist.x64.exe 直接安装 vc_redist_x64/86.exe.
下载:httpd-2.4.17-win64-VC14.zip
配置环境变量:path增加D:\Apache24\bin;
解压到指定目录 修改配置文件: http.conf (下面内容中的ServerRoot改成你自己的实际Apche解压路径)
ServerRoot "D:/Apache24"
……
Listen 127.0.0.1:8081 #修改端口号
……
ServerName www.example.com:8081
……
DocumentRoot "D:/Apache24/htdocs"

……
ScriptAlias /cgi-bin/ "D:/Apache24/cgi-bin/"
……

AllowOverride None
Options None
Require all granted

启动apache服务:
cmd>httpd
http://127.0.0.1:8081/index.html
It works! apache配置成功
安装mod_wsgi
先安装:pip install wheel
安装mod_wsgi-4.4.23+ap24vc14-cp35-cp35m-win_amd64.whl
下载:mod_wsgi-4.4.23+ap24vc14-cp35-cp35m-win_amd64.whl
地址:http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi
pip 安装:pip install mod_wsgi-4.4.23+ap24vc14-cp35-cp35m-win_amd64.whl
配置Apache2.4、mod_wsgi、django项目工程
1. 将C:\Python35\mod_wsgi.so 拷贝至 D:\Apache24\modules下
(mod_wsgi.so 只有mod_wsgi-4.4.23+ap24vc14-cp35-cp35m-win_amd64.whl安装成功后才能找到)
2.修改apache2.4的http.conf文件:
#添加mod_wsgi.so 模块
LoadModule wsgi_module modules/mod_wsgi.so
3.配置django项目 修改http.conf
#添加mod_wsgi.so 模块
LoadModule wsgi_module modules/mod_wsgi.so
#指定静态资源路径
Alias /statics/ F:/pydj/newsCollection/toutiao/statics/

Require all granted

#指定newsCollection项目的wsgi.py配置文件路径
WSGIScriptAlias / F:/pydj/newsCollection/newsCollection/wsgi.py
#指定项目路径
WSGIPythonPath F:/pydj/newsCollection


Require all granted


wsgi.py内容:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myweb.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
#注意上面的myweb,是改成自己的项目名称,比如上图中 newsCollection。参考上上图中的目录结构。
配置django工程setting.py
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
最后告诉一点 Apche 启动的时候报错会有log, httpd-2.4.23-x64-vc14-r3\Apache24\logs 目录下 error信息,慢慢排错
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对中文源码网的支持。

相关内容