準(zhǔn)備
需要機(jī)器具備基本的工具環(huán)境:
- python
- pip
- flask
- gunicorn 一個(gè)給 UNIX 用的 WSGI HTTP 服務(wù)器
- git
- supervisor
配置
- gunicorn
gunicorn <appname>:app
appname 是flask應(yīng)用的名字
成功運(yùn)行可以看到
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 {
listen 80; ## 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服務(wù)
service nginx restart