世良情感网

理想国真恵玩Python从入门到精通042服务器部署Flask项目

Linux发行版本 ubuntu18需要安装的环境需要安装nginxnginx配置打开/etc/nginx/sites-

Linux发行版本 ubuntu18

需要安装的环境

需要安装nginx

nginx配置

打开

/etc/nginx/sites-enabled/default

文件

server {    # 监听80端口    listen 80;    # 本机    server_name localhost;    # 默认请求的url    location / {        #请求转发到gunicorn服务器        proxy_pass http://127.0.0.1:5001;        #设置请求头,并将头信息传递给服务器端        proxy_set_header Host $host;    }}

绿色独角兽运行命令

gunicorn -w 4 -b 127.0.0.1:5001 运行文件名称:Flask程序实例名

比如

gunicorn -w 4 -b 127.0.0.1:5001 hello:app