nginx + gunicorn + flask项目发布
程序员文章站
2022-06-24 14:26:58
程序安装(linux mint) 安装: 安装: 配置 nginx默认配置信息在 flask项目部署 复制flask程序至 启动gunicorn: ,` w mission manager flask py`文件 启动 服务:`service nginx start` ......
程序安装(linux mint)
-
gunicorn
安装:pip install gunicorn
-
nginx
安装:sudo apt-get install nginx
配置
nginx默认配置信息在/etc/nginx/sites-enabled/default
server { listen 8300 default_server;#默认端口设置位置 listen [::]:8300 default_server ipv6only=on; root /usr/share/nginx/html; index index.html index.htm; # make site accessible from http://localhost/ server_name localhost; location / { # first attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; # uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } server { listen 8200;#nginx对外监听端口设置 server_name my.com;#网站域名绑定 #root html; #index index.html index.htm; location /auth {#auth为flask程序你的蓝图,如果没有设置蓝图则为/ #try_files $uri $uri/ =404; proxy_pass http://0.0.0.0:8100;#gunicorn启动flask的网址 proxy_set_header host $host; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; client_max_body_size 50m;#服务器上传文件大小上限 } location /static {#静态文件static文件夹所在目录 root /var/www/mission-manager/; } }
flask项目部署
- 复制flask程序至
/var/www/
- 启动gunicorn:
gunicorn -w 2 -b 127.0.0.0:8100 mission-manager:app
,-w
进程数量,mission-manager
为flask
程序主函数所在py
文件 - 启动
nginx
服务:service nginx start
推荐阅读
-
在CentOS上配置Nginx+Gunicorn+Python+Flask环境的教程
-
用uWSGI和Nginx部署Flask项目的方法示例
-
如何基于nginx+uWSGI+django+virtualenv+supervisor部署发布web项目
-
nginx + flask + uwsgi + centos + python3 搭建web项目
-
建立网站用nginx-gunicorn部署django项目的过程
-
nginx+uwsgi+flask+supervisor 项目部署
-
nginx+supervisor+gunicorn+flask
-
阿里云ECS部署python,flask项目,简单易懂,无需nginx和uwsgi
-
Net Core Web Api项目与在NginX下发布的方法
-
nginx + gunicorn + flask项目发布