首页 > 编程 > Python > 正文

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

2020-02-23 04:32:06
字体:
来源:转载
供稿:网友

环境介绍

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" <Directory "D:/Apache24/htdocs"> …… ScriptAlias /cgi-bin/ "D:/Apache24/cgi-bin/" …… <Directory "D:/Apache24/cgi-bin">  AllowOverride None  Options None  Require all granted </Directory>

启动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/<Directory F:/pydj/newsCollection/toutiao/statics> Require all granted </Directory>   #指定newsCollection项目的wsgi.py配置文件路径 WSGIScriptAlias / F:/pydj/newsCollection/newsCollection/wsgi.py#指定项目路径 WSGIPythonPath F:/pydj/newsCollection   <Directory F:/pydj/newsCollection/newsCollection>  <Files wsgi.py>   Require all granted  </Files></Directory>


wsgi.py内容:

import osos.environ.setdefault("DJANGO_SETTINGS_MODULE", "myweb.settings")from django.core.wsgi import get_wsgi_applicationapplication = get_wsgi_application()            
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表