部署Flask应用

准备 需要机器具备基本的工具环境:

  • python
  • pip
  • flask
  • gunicorn 一个给 UNIX 用的 WSGI HTTP 服务器
  • git
  • supervisor
配置
  • gunicorn
gunicorn :app

【部署Flask应用】appname 是flask应用的名字
成功运行可以看到
017-02-27 16:41:30 [4332] [INFO] Starting gunicorn 0.14.5 2017-02-27 16:41:30 [4332] [INFO] Listening at: http://127.0.0.1:8000 (4332) 2017-02-27 16:41:30 [4332] [INFO] Using worker: sync 2017-02-27 16:41:30 [4335] [INFO] Booting worker with pid: 4335

  • nginx
    /etc/nginx/sites-available/下的default文件
server { listen80; ## listen for ipv4; this line is default and implied ... location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } ...

配置后记得重新启动nginx服务
service nginx restart

    推荐阅读