deploy: 本地部署完成 - Gunicorn + Nginx 配置
This commit is contained in:
9
TOOLS.md
9
TOOLS.md
@@ -58,3 +58,12 @@ Add whatever helps you do your job. This is your cheat sheet.
|
||||
- **数据库**: cssc
|
||||
- **用户**: coder
|
||||
- **密码**: 825670wl
|
||||
|
||||
## 云服务器
|
||||
|
||||
### 城市手册部署
|
||||
|
||||
- **主机**: cssc.datalibstar.com
|
||||
- **用户**: mashen
|
||||
- **密码**: 825670@MashenClaw
|
||||
- **状态**: ⚠️ SSH 密码认证失败,需要 SSH Key
|
||||
|
||||
Binary file not shown.
80
city-manual/deploy.sh
Normal file
80
city-manual/deploy.sh
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
# 城市手册 - 自动部署脚本
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 开始部署城市手册项目..."
|
||||
|
||||
# 1. 安装依赖
|
||||
echo "📦 安装 Python 依赖..."
|
||||
cd /root/.openclaw/workspace/city-manual/backend
|
||||
pip3 install -r requirements.txt --break-system-packages -q
|
||||
|
||||
# 2. 数据库迁移
|
||||
echo "🗄️ 执行数据库迁移..."
|
||||
python3 manage.py migrate --noinput
|
||||
|
||||
# 3. 收集静态文件
|
||||
echo "📁 收集静态文件..."
|
||||
python3 manage.py collectstatic --noinput
|
||||
|
||||
# 4. 创建 Gunicorn 服务
|
||||
echo "⚙️ 创建 Gunicorn 服务..."
|
||||
cat > /etc/systemd/system/city-manual.service << EOF
|
||||
[Unit]
|
||||
Description=City Manual Gunicorn Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/root/.openclaw/workspace/city-manual/backend
|
||||
ExecStart=/usr/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/city-manual.sock city_manual.wsgi:application
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable city-manual
|
||||
systemctl start city-manual
|
||||
|
||||
# 5. 配置 Nginx
|
||||
echo "🌐 配置 Nginx..."
|
||||
cat > /etc/nginx/sites-available/city-manual << 'EOF'
|
||||
server {
|
||||
listen 80;
|
||||
server_name cssc.datalibstar.com;
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
|
||||
location /static/ {
|
||||
alias /root/.openclaw/workspace/city-manual/backend/static/;
|
||||
}
|
||||
|
||||
location /media/ {
|
||||
alias /root/.openclaw/workspace/city-manual/backend/media/;
|
||||
}
|
||||
|
||||
location / {
|
||||
include proxy_params;
|
||||
proxy_pass http://unix:/run/city-manual.sock;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
ln -sf /etc/nginx/sites-available/city-manual /etc/nginx/sites-enabled/
|
||||
nginx -t
|
||||
systemctl restart nginx
|
||||
|
||||
# 6. 导入示例数据
|
||||
echo "📊 导入示例数据..."
|
||||
python3 manage.py seed_data
|
||||
|
||||
echo ""
|
||||
echo "✅ 部署完成!"
|
||||
echo ""
|
||||
echo "📍 访问地址:http://cssc.datalibstar.com"
|
||||
echo "📍 Admin: http://cssc.datalibstar.com/admin"
|
||||
echo "📍 测试账号:demo / demo123"
|
||||
3
city-manual/gunicorn_start.sh
Normal file
3
city-manual/gunicorn_start.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
cd /root/.openclaw/workspace/city-manual/backend
|
||||
exec gunicorn --workers 3 --bind 0.0.0.0:8000 city_manual.wsgi:application
|
||||
Reference in New Issue
Block a user