Apache部署Django项目(windows)
简介
由于最近python3.6没有mod_wsgi,所以将Python换成了3.5...啊浪费好多时间,等于少活了一段时间...TMD,留给有缘人看到我这篇博客吧..
首先最近一点时间mod_wsgi没有支持python3.6的所以换成3.5就可以了,
CP对应python版本,VC要和下载的Apache一样
安装前提
- python保证是3.5的64位,(目前一段时间).
- Apache (64)
- django版本(我是2.1.4)
- mod_wsgi版本要对应起来
文件分享
python解释器...持续更新中
Apache...
mod_wsgi模块安装
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi
下载好放在python安装路径的scripts里面 切进去
D:\python35\Scripts> pip install mod_wsgi-4.5.24+ap24vc14-cp35-cp35m-win_amd64.whl
成功会有successful标示...
然后运行
D:\python35\Scripts> mod_wsgi-express module-config
得到输出的三个结果
LoadFile "d:/python35.dll"
LoadModule wsgi_module "d:/python35/lib/site-packages/mod_wsgi/server/mod_wsgi.cp35-win_amd64.pyd"
WSGIPythonHome "d:/python35"
Apache参数修改
将三个结果复制到D:\Apache\config\httpd.conf最下面
设置django项目和wsgi.py路径
WSGIScriptAlias / D:/projectname/projectname/wsgi.py
WSGIPythonPath D:/projectname
<Directory D:/projectname/projectname>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
端口
Listen 8000
ServerName localhost:8000
模板设置
DocumentRoot "D:/projectname/templates"
<Directory "D:/projectname/templates">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
在D:\Apache\bin里面双击httpd.exe就可以运行了
在网址上输入127.0.0.1:8000就可以运行django项目了
命令
D:\Apache\bin> httpd -k install D:\Apache\bin> httpd -k start
install成功之后也可以使用net start xxx
静态文件
<Directory "D:/projectname/projectname/static/">
Require all granted
</Directory>
Alias /static/ "D:/projectname/projectname/static/"
...持续更新
参考https://blog.csdn.net/dave_haijie/article/details/78060888