nginx默认生成配置文件在/etc/nginx/nginx.conf要注意配置server 时 server_name为云主机的ip地址;
配置gunicorn 代理时
location /{
//gunicorn地址 http://0.0.0.0:8000
//有资料上说监听所有的ip地址,不然执行gunicorn时找不到服务器
}
静态文件应该放于
location /static {
}
gunicorn 安装后运行时命令为
gunicorn -w 2 test:app
这里没有设置绑定的IP地址,因为nginx已经设置,test 为web目录下的test.py文件 app 为test.py 文件中定义的flask应用
supervisor 配置文件要在安装后 用echo_supervisord_conf > /etc/supervisor/supervisord.conf生成。在其中打开最后项[include]
file=/etc/supervisor/config.d/*.ini
设置program,
执行gunicorn命令 command=
web文件所在目录 directory=
user=root
等内容
最后记着 先 supervisord -c /etc/supervisor/supervisord.conf
后 supervisorctl
reload status stop 等等