71

CentOS7部署Flask+Gunicorn+Nginx+Supervisor-自由之路

 5 years ago
source link: http://blog.51cto.com/wangy8961/2117429
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
当你用Flask框架在本地完全开发好一个应用程序后,想部署到服务器上,让互联网用户可以访问它,这与搭建本地开发环境还是有一些不一样的地方。首先,我们假设在服务器上安装了CentOS-7系统,使用git来上传和后续更新程序源代码,由于Flask自带的开发Web服务器性能不足以应对生产环境的并发访问,所以我们使用Gunicorn来替代它,同时,整个Web应用有许多静态资源,而Nginx非常善于处理这类请求,所以在Gunicorn前面再部署Nginx来提供静态资源服务,将其它请求反向代理给后面的Flask应用服务器Gunicorn。最后,为保证我们的Web应用持续提供服务,使用Supervisor来监控MongoDB/Gunicorn/Nginx的服务状态,当某一服务意外停止后,它会自动重启它。另外,我们也可以用Fabric实现这整个生产环境的部署过程自动化。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK