自托管部署
本文介绍如何在自己的服务器上部署 Basemulti。
环境要求
- Node.js 18.0+
- Git
- 数据库(支持以下任一种):
- MySQL 5.7+
- PostgreSQL 10+
- SQLite 3+
基础部署
1. 获取代码
bash
git clone https://github.com/basemulti/basemulti.git
cd basemulti2. 安装依赖
bash
npm installbash
yarn installbash
pnpm install3. 配置环境
复制环境变量示例文件:
bash
cp .env.example .env编辑 .env 文件,配置必要的环境变量:
- 数据库连接信息
- 应用密钥
- 其他配置项
4. 构建应用
bash
npm run buildbash
yarn buildbash
pnpm build5. 启动应用
开发环境
bash
npm run devbash
yarn devbash
pnpm dev生产环境
bash
npm startbash
yarn startbash
pnpm start生产环境部署方案
使用 PM2 部署
PM2 是一个流行的 Node.js 进程管理器,适合生产环境使用。
安装 PM2
bashnpm install -g pm2bashyarn global add pm2bashpnpm add -g pm2创建 PM2 配置
创建
ecosystem.config.js:jsmodule.exports = { apps: [{ name: 'basemulti', script: 'npm', args: 'start', env: { NODE_ENV: 'production' } }] }启动应用
bashpm2 start ecosystem.config.js管理应用
bashpm2 status # 查看状态 pm2 logs basemulti # 查看日志 pm2 restart basemulti # 重启应用
使用 Vercel 部署
Vercel 提供了零配置的部署方案。
准备工作
- Fork Basemulti 仓库
- 注册 Vercel 账号
- 准备数据库(不支持 SQLite)
导入项目
- 登录 Vercel
- 点击 "New Project"
- 选择 Fork 的仓库
- 点击 "Import"
配置环境变量 在 Vercel 项目设置中添加:
BASEMULTI_KEYNEXT_PUBLIC_URL- 数据库配置
- 其他必要的环境变量
部署配置
创建
vercel.json:json{ "buildCommand": "npm run build", "outputDirectory": ".next", "devCommand": "npm run dev", "installCommand": "npm install", "framework": "nextjs" }完成部署
- 点击 "Deploy"
- 等待部署完成
- 使用 Vercel 提供的 URL 访问应用
访问应用
- 开发环境:http://localhost:3000
- 生产环境:根据您的部署方式访问对应地址