Files
vue-driven-cloud-storage/INSTALL_GUIDE.md
237899745 4350113979 fix: 修复配额说明重复和undefined问题
- 在editStorageForm中初始化oss_storage_quota_value和oss_quota_unit
- 删除重复的旧配额说明块,保留新的当前配额设置显示

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 19:39:53 +08:00

6.0 KiB
Raw Permalink Blame History

玩玩云 - 手动部署指南

本指南详细说明如何手动部署玩玩云系统。

环境要求

服务器要求

  • 操作系统: Linux (Ubuntu 18.04+ / Debian 10+ / CentOS 7+)
  • 内存: 最低 1GB RAM推荐 2GB+
  • 磁盘空间: 至少 2GB 可用空间

软件依赖

  • Node.js: 20.x LTS
  • Nginx: 1.18+
  • Git: 2.x

部署步骤

1. 安装 Node.js 20.x

Ubuntu/Debian

# 安装 NodeSource 仓库
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

# 安装 Node.js
sudo apt-get install -y nodejs

# 验证安装
node -v  # 应显示 v20.x.x
npm -v

CentOS/RHEL

# 安装 NodeSource 仓库
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -

# 安装 Node.js
sudo yum install -y nodejs

# 验证安装
node -v
npm -v

2. 安装 Nginx

Ubuntu/Debian

sudo apt-get update
sudo apt-get install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx

CentOS/RHEL

sudo yum install -y epel-release
sudo yum install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx

3. 克隆项目

# 创建部署目录
sudo mkdir -p /var/www
cd /var/www

# 克隆项目
sudo git clone https://git.workyai.cn/237899745/vue-driven-cloud-storage.git wanwanyun

# 设置目录权限
sudo chown -R $USER:$USER /var/www/wanwanyun

4. 安装后端依赖

cd /var/www/wanwanyun/backend

# 安装依赖
npm install --production

# 创建数据目录
mkdir -p data storage

5. 配置环境变量

# 复制环境变量模板
cp .env.example .env

# 编辑配置文件
nano .env

必须修改的配置

# 生成随机 JWT 密钥
JWT_SECRET=$(node -e "console.log(require('crypto').randomBytes(32).toString('hex'))")
echo "JWT_SECRET=$JWT_SECRET"

# 修改管理员密码
ADMIN_PASSWORD=你的强密码

6. 配置 Nginx

# 复制 Nginx 配置
sudo cp /var/www/wanwanyun/nginx/nginx.conf /etc/nginx/sites-available/wanwanyun

# 修改配置中的路径
sudo sed -i 's|/usr/share/nginx/html|/var/www/wanwanyun/frontend|g' /etc/nginx/sites-available/wanwanyun
sudo sed -i 's|backend:40001|127.0.0.1:40001|g' /etc/nginx/sites-available/wanwanyun

# 创建软链接启用配置
sudo ln -sf /etc/nginx/sites-available/wanwanyun /etc/nginx/sites-enabled/

# 删除默认配置(可选)
sudo rm -f /etc/nginx/sites-enabled/default

# 测试配置
sudo nginx -t

# 重新加载 Nginx
sudo systemctl reload nginx

7. 配置系统服务

创建 systemd 服务文件:

sudo tee /etc/systemd/system/wanwanyun.service > /dev/null << 'EOF'
[Unit]
Description=WanWanYun Cloud Storage Service
After=network.target

[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/var/www/wanwanyun/backend
ExecStart=/usr/bin/node server.js
Restart=always
RestartSec=10
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
EOF

设置目录权限:

sudo chown -R www-data:www-data /var/www/wanwanyun

启动服务:

sudo systemctl daemon-reload
sudo systemctl enable wanwanyun
sudo systemctl start wanwanyun

8. 验证部署

# 检查服务状态
sudo systemctl status wanwanyun

# 检查后端是否启动
curl http://127.0.0.1:40001/api/health

# 检查 Nginx 是否正常
curl http://localhost

配置 HTTPS推荐

使用 Let's Encrypt 免费证书

# 安装 Certbot
sudo apt-get install -y certbot python3-certbot-nginx

# 获取证书(替换为你的域名和邮箱)
sudo certbot --nginx -d your-domain.com --email your@email.com --agree-tos --non-interactive

# 验证自动续期
sudo certbot renew --dry-run

更新后端配置

获取证书后,编辑 /var/www/wanwanyun/backend/.env

ENFORCE_HTTPS=true
COOKIE_SECURE=true
TRUST_PROXY=1

重启服务:

sudo systemctl restart wanwanyun

防火墙配置

UFW (Ubuntu)

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

firewalld (CentOS)

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

日常维护

查看日志

# 查看服务日志
sudo journalctl -u wanwanyun -f

# 查看 Nginx 错误日志
sudo tail -f /var/log/nginx/error.log

更新系统

cd /var/www/wanwanyun
sudo git pull
cd backend && npm install --production
sudo systemctl restart wanwanyun

备份数据

# 备份数据库
sudo cp /var/www/wanwanyun/backend/data/database.db /backup/database.db.$(date +%Y%m%d)

# 备份上传文件(本地存储模式)
sudo tar -czf /backup/storage-$(date +%Y%m%d).tar.gz /var/www/wanwanyun/backend/storage/

故障排查

服务无法启动

# 检查日志
sudo journalctl -u wanwanyun -n 100

# 检查端口占用
sudo lsof -i :40001

# 检查 Node.js 版本
node -v

无法访问网页

# 检查 Nginx 状态
sudo systemctl status nginx

# 检查 Nginx 配置
sudo nginx -t

# 检查防火墙
sudo ufw status

数据库错误

# 检查数据库文件权限
ls -la /var/www/wanwanyun/backend/data/

# 修复权限
sudo chown -R www-data:www-data /var/www/wanwanyun/backend/data/

性能优化

启用 Nginx 缓存

在 Nginx 配置的 location / 中添加:

location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
    expires 30d;
    add_header Cache-Control "public, immutable";
}

配置日志轮转

sudo tee /etc/logrotate.d/wanwanyun > /dev/null << 'EOF'
/var/log/nginx/*.log {
    daily
    missingok
    rotate 14
    compress
    delaycompress
    notifempty
    create 0640 www-data adm
    sharedscripts
    postrotate
        [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
    endscript
}
EOF

相关链接