01. Windows 下安装 Python3.7+Django2.1+Apache2.4
0

1.Python3.7安装

官网下载Python3.7的安装包,我的系统是64位,所以选择的64位安装包,自定义安装需要勾选为所有用户安装和加入环境变量。

2.安装Apache2.4

我这里安装的是Wamp3.1的集成环境,里面集成了Apache2.4,也是64位的,必须要和Python相对应,不然会导致Apache发生错误。

3.安装Django2.1和mysql客户端
pip intsall Django //安装最新的Django
pip install mysqlclient //安装mysql客户端
4.安装mod_wsgi
pip install mod_wsgi //安装mod_wsgi

安装成功后在python安装包下\Python37\Scripts下执行:

mod_wsgi-express module-config

执行此命令会输入三行内容:

LoadFile "d:/soft/python/python37/python37.dll"
LoadModule wsgi_module "d:/soft/python/python37/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
WSGIPythonHome "d:/soft/python/python37"

将此内容拷贝备用。

5.配置Apache httpd.cnf

将第4步生成的三行内容拷贝到http.cof中,保存并重启Apache即可,内容如下:

#mod_wsgi设置
LoadFile "d:/soft/python/python37/python37.dll"
LoadModule wsgi_module "d:/soft/python/python37/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
WSGIPythonHome "d:/soft/python/python37"
#指定项目的wsgi.py配置文件路径
WSGIScriptAlias / D:/wenjunting/python/app/app/wsgi.py
#指定项目路径
WSGIPythonPath  D:/wenjunting/python/app
#指定静态文件位置 ,给与访问权限
Alias /static/ D:/wenjunting/python/app/collectstatic/  #必须把admin模块的文件一同打包到此目录下
<Directory D:/wenjunting/python/app/collectstatic>
    Require all granted
</Directory>
<Directory D:/wenjunting/python/app/app>
<Files wsgi.py>
    Require all granted
</Files>
</Directory>
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

  请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!