部署flask(nginx,gunicron,supervisor)
2022/4/4 7:21:46
本文主要是介绍部署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;
}
这篇关于部署flask(nginx,gunicron,supervisor)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-13用Nginx防范DDoS攻击的那些事儿
- 2024-12-13用Terraform在AWS上搭建简单NGINX服务器指南
- 2024-10-29Nginx发布学习:从入门到实践的简单教程
- 2024-10-28Nginx发布:新手入门教程
- 2024-10-21nginx 怎么设置文件上传最大20M限制-icode9专业技术文章分享
- 2024-10-17关闭 nginx的命令是什么?-icode9专业技术文章分享
- 2024-09-17Nginx实用篇:实现负载均衡、限流与动静分离
- 2024-08-21宝塔nginx新增8022端口方法步骤-icode9专业技术文章分享
- 2024-08-21nginx配置,让ws升级为wss访问的方法步骤-icode9专业技术文章分享
- 2024-08-15nginx ws代理配置方法步骤-icode9专业技术文章分享