部署flask(nginx,gunicron,supervisor)

supervisor apt安装

配置文件

Nginx(

[program:Nginx]
command = /usr/sbin/Nginx -g 'daemon off;'
startsecs=0
autostart=true
autorestart=true
stdout_logfile=/home/maj/flask/log/Nginx_sup.log
redirect_stderr=true
priority=10
stopasgroup=true
killasgroup=true
stopsignal=INT
startsecs=10
startretries=10

)

gunicron(

[program:gunicorn]
command=/home/maj/flask/venv/bin/gunicorn -w4 -b0.0.0.0:8000 app:app ; supervisor启动命令
directory=/home/maj/flask ; 项目的文件夹路径
startsecs=0 ; 启动时间
stopwaitsecs=0 ; 终止等待时间
autostart=true ; 是否自动启动
autorestart=true
stopasgroup=true ; 是否自动重启
stdout_logfile=/home/maj/flask/log/gunicorn.log ; log 日志
stderr_logfile=/home/maj/flask/log/gunicorn.err
environment=MAIL_USERNAME="xxx",MAIL_PASSWORD="xxx",SECRET_KEY="xxx"

)

Nginx配置文件:

server {
listen 80 default_server;
listen [::]:80 default_server;

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /home/maj/flask;

# Add index.PHP to the list if you are using PHP
index index.html index.htm index.Nginx-debian.html;

server_name _;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.

# try_files $uri $uri/templates/index.html$is_args$query_string;
proxy_pass http://0.0.0.0:8000/;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


}


location /static {
# root /static;
alias /home/maj/flask/static;
}

相关文章

Nginx (engine x) 是一个高性能的HTTP和反向代理服务,也是一...
本地项目配置 1 复制 luffy/settings/dev.py为prop.py 修改l...
nginx不仅可以隐藏版本信息,还支持自定义web服务器信息 先看...
一 、此次漏洞分析 1 nginx HTTP/2漏洞 [nginx-announce] ng...
###进入nginx 目录cd /usr/local/nginx###递归显示 2 级目录...
在cmd命令窗口输入下面命令进行查看 tasklist /fi "ima...