腾讯云部署flask
安装环境
sudo apt install python3-dev python3-pip python3-venv
创建虚拟环境
python3 -m venv venv
启动虚拟环境
source venv/bin/activate
安装依赖
pip3 install -r requirements.txt
设置PATH
export FLASK_APP=blog.py
初始化数据库
flask db init
flask db migrate
flask db upgrade
启动
python3 blog.py
安装gunicorn
pip3 install gunicorn
启动
gunicorn -w 4 -b 127.0.0.1:5000 blog:app
安装nginx
sudo apt install nginx
配置nginx
sudo vim /etc/nginx/sites-available/default
同时新建目录/var/www/html/static
设置nginx文件上传大小限制,编辑server
client_max_body_size 10M;
重启nginx
sudo service nginx restart