Flask 应用程序如何部署到服务器?

2016-04-01 12:12:12 +08:00
 biexiawo
项目已经写好,但不了解如何部署到服务器,求哪位朋友帮忙指导下,如果有这方面的教程或者博客就太好了
18943 次点击
所在节点    Python
29 条回复
tvallday
2016-04-01 12:17:14 +08:00
根据我的经验,你需要一个 web server ,还要有反向代理 Nginx ,你也可以不用 Nginx ,但是现在这么流行学学也没坏处。 web server 我用的是 Unicorn.
在 Google 上搜 Gunicorn flask server 。你就能找到答案。
tvallday
2016-04-01 12:19:57 +08:00
写错,应该是 Gunicorn 不是 Unicorn , Unicorn 是 Ruby 的 server 。还有其他的 server 你也可以看一下。当然你最好把 Gunicorn 启动加到 system service 里面去,然后你就可以 sudo systemctl gunicorn start 启动了。当然添加 system service 也有很多种办法, GoogleForWhatYouWant.
csdreamdong
2016-04-01 12:24:16 +08:00
apache + mod_wsgi
biexiawo
2016-04-01 12:36:13 +08:00
@tvallday Thank you very much !!
biexiawo
2016-04-01 12:37:23 +08:00
@csdreamdong 官方文档就是推荐的这种方法,但其介绍的太简略
Kilerd
2016-04-01 12:40:42 +08:00
nginx uwign/gunicorn gevent superivor 一套搞定。
biexiawo
2016-04-01 12:43:01 +08:00
@Kilerd 朋友能给推荐个教程吗?感激不尽
aiver
2016-04-01 12:46:37 +08:00
一般是 Nginx + Gunicorn + Supervisor + Flask 部署,这里有一个在阿里云上部署的例子,你可以参考: http://www.simpleapples.com/2015/06/configure-nginx-supervisor-gunicorn-flask/,我之前也是在阿里云上部署的
clino
2016-04-01 12:51:35 +08:00
uwsgi 也很不错,跟 nginx 配合起来用
lhbc
2016-04-01 13:06:01 +08:00
uwsgi, 搜索一下就有文档,非常简单。
uwsgi 是多进程的,简单成熟。
yjd
2016-04-01 13:06:18 +08:00
重点是安全,不然就等着被 xx 了。
crazyxin1988
2016-04-01 13:16:55 +08:00
virtualenv+supervisor+nginx+gunicorn
strahe
2016-04-01 13:29:02 +08:00
搜一下 uwsgi + nginx 教程很多.
wellsc
2016-04-01 13:37:02 +08:00
官方文档和《 flask web 开发》不是教了你 N 种方法吗?伸手就行了
biexiawo
2016-04-01 16:29:35 +08:00
@crazyxin1988 部署好了,用你的这个方法, 3Q !
biexiawo
2016-04-01 16:30:39 +08:00
@Kilerd 恩,谢谢你的指导!
biexiawo
2016-04-01 16:34:36 +08:00
@clino 嗯嗯,我还很菜但我会努力学的,谢谢!
biexiawo
2016-04-01 16:34:57 +08:00
@csdreamdong 谢谢!
biexiawo
2016-04-01 16:42:25 +08:00
@wellsc 嗯,我还要努力,谢谢
Abirdcfly
2016-04-02 00:45:08 +08:00
给一个新浪云 SAE 部署的例子: http://abirdcfly.github.io/2016/03/07/flask-to-sae/

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/267868

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX