centos 使用uwsgi部署flask


centos 宝塔 新建站点

用virtualenv建虚拟环境 virtualenv -p /usr/bin/python3 venv3

source venv3/bin/activate

pip install -r requirements.txt

python setup.py install

source venv3/bin/deactivate

pip install uwsgi

uwsgi.ini

[uwsgi]
# 外部访问地址,可以指定多种协议,现在用http便于调试,之后用socket
# http方式
socket = 127.0.0.1:8008
# 项目路径
pythonpath= /www/wwwroot/rkj.cn
# 虚拟环境的目录路径
virtualenv = /www/wwwroot/rkj.cn/venv3
# 主程序文件
wsgi-file=%(pythonpath)/app/apps.py
# flask项目创建的application
callable = app
#主线程
master = true
# 处理器数
processes = 1
# 线程数
threads = 2
daemonize=/www/wwwroot/rkj.cn/jz.log
pidfile=/www/wwwroot/rkj.cn/uwsgi.pid
vacuum=True
max-requests=5000

uwsgi --ini uwsgi.ini

/www/server/panel/vhost/nginx/*.conf

/www/server/nginx/sbin/nginx -s reload

nginx.conf ```

configuration of the server

server {

# the port your site will be served on
listen      80;
# the domain name it will serve for
server_name rkj.cn; # substitute your machine's IP address or FQDN
charset     utf-8;

# max upload size
client_max_body_size 75M;   # adjust to taste



# Finally, send all non-media requests to the Django server.
location / {
    uwsgi_pass  127.0.0.1:8008;
    include     uwsgi_params; # the uwsgi_params file you installed
}

}

'''