Apache部署Django项⽬(windows)
Apache部署Django项⽬(windows)
简介
由于最近python3.6没有mod_wsgi,所以将Python换成了啊浪费好多时间,等于少活了⼀段时间...TMD,留给有缘⼈看到我这篇博客吧..⾸先最近⼀点时间mod_wsgi没有⽀持python3.6的所以换成3.5就可以了,
CP对应python版本,VC要和下载的Apache⼀样
安装前提
python保证是3.5的64位,(⽬前⼀段时间).
Apache (64)
django版本(我是2.1.4)
mod_wsgi版本要对应起来
⽂件分享
python解释器...持续更新中
<
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\f最下⾯设置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">
django登录注册功能Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
在D:\Apache\bin⾥⾯双击就可以运⾏了
在⽹址上输⼊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/"
...持续更新
Apache配置总结
LoadFile "d:/python35/python35.dll"
LoadModule wsgi_module "d:/python35/lib/site-packages/mod_wsgi/server/mod_wsgi.cp35-win_amd64.pyd" WSGIPythonHome "d:/python35"
<VirtualHost *:8000>
#这⾥填写你的服务器ip地址
ServerName localhost
#设置⼯程中的wsgi路径(django项⽬⾥的wsgi.py⽂件)
#flask项⽬的话,需要⾃建wsgi.py⽂件,在把路径添加到此
WSGIScriptAlias / D:/Django/wufei/wufei/wsgi.py
#设置访问权限
<Directory D:/Django/wufei/wufei>
<Files wsgi.py>
#apache2.4及以上访问权限设置格式
Require all granted
</Files>
</Directory>
#静态⽂件夹权限
Alias /static D:/Django/wufei/static
<Directory D:/Django/wufei/static>
Require all granted
</Directory>
</VirtualHost>
WSGIPythonPath D:/Django/wufei
参考blog.csdn/dave_haijie/article/details/78060888
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论