使用nginx+uWSGI部署flask应用

时间:2021-06-03 20:32:25

nginx配置文件一般放在 /etc/nginx/sites-enabled 或者 /etc/nginx/conf.d 这两个文件夹下面,后序名为 .conf,最简单的配置如下:

server {
    listen 5000;
    server_name localhost;
    charset utf-8;

    location / {
         include uwsgi_params;
         uwsgi_pass 127.0.0.1:3031;
     }
}

nginx基本命令:

service nginx start

service nginx restart

nginx -s reload

nginx -s stop



uwsgi的flask最简单配置如下:

[uwsgi]
socket=127.0.0.1:3031
wsgi-file=/path/to/your/project/run.py
callable=app
processes=4
threads=2

uwsgi配置使用方式:

uwsgi uwsgi.ini