supervisor +nginx+virtualenv +gunicorn+flask  [python web应用部署]

2019/01 17 14:01

supervisor(进程管理多应用管理,快速恢复) +nginx+virtualenv +gunicorn(python Wsgi http server)+flask

supervisor 不支持python3

#yum install supervisor

pip install supervisor

-------

requirements.txt

flask

gunicorn

----------

 

virtualenv venv

source venv/bin/activate

pip install -r requirements.txt

 

gunicorn -b 0.0.0.0:8080 run:app

 

deactivate


app.py

from flask import Flask

app=Flask(__name__)

@app.route(/)

def index():

return "hello"

if __name__=="__main__":

app.run(prot=8080)

------

 

---------

vi /etc/nginx/sites-available/app.conf

server{

listen:80;

location /static{

alias /home/shi/apphome/static}

location /{

proxy_pass http://127.0.0.1:9000;

}

}

---------

cd /etc/nginx/sites-enabled

ln -s ../sites-abailable/app.conf .

service nginx reload

cd /etc/supervisor/conf.d

------

vi app.conf

[program:todo]

command =/home/shin/apphome/venv/bin/gunicorn -b 127.0.0.1:900 run:app

directory= /home/shin/apphome

--------

supervisorctl

reload

status

start app

--转载请注明: http://91o.cc/supervisor-nginxvirtualenv-gunicornflask-python-web%e5%ba%94%e7%94%a8%e9%83%a8%e7%bd%b2/