作为 Python 小组大作业的仓库
pip install flask
下面均以ubuntu环境举例
sudo apt-get update #更新源
sudo apt-get install mysql-server #安装
sudo apt update
sudo apt install redis-server
# 安装虚拟环境
pip install virtualenv`
# 创建虚拟文件夹并进入
virtualenv backend/venv`
# 激活虚拟环境并安装必需包
./backend/venv/bin/activate
pip install -r requirements.txt
# 记得修改backend/myblog/settings.py 下的mysql数据库设置
cd backend
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update && sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 官方源
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# 官方源
$ echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo systemctl enable docker && sudo systemctl start docker
sudo groupadd docker && sudo usermod -aG docker $USER
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://kzev4hva.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
打开以下网站:docker/compose: Define and run multi-container applications with Docker (github.com)
选择合适的版本并下载
重命名为docker-compose
并 将其移到/usr/local/bin
中
修改前端static/config/config.js文件中的后端地址和后端myblog/settings.py中的mysql和redis地址
在项目根目录下运行docker-compose up -d
即可