5 分钟内让你的 SageGuard 运行起来
版本 14.0 或更高
sudo apt install postgresql postgresql-contrib
本地 AI 推理引擎
curl -fsSL https://ollama.ai/install.sh | sh
版本 18.0 或更高
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - && sudo apt-get install -y nodejs
从 GitHub 克隆 SageGuard 项目源码
git clone https://github.com/your-repo/mtphelper.git
cd mtphelper
复制并编辑环境配置文件
cp .env.example .env
nano .env
# Telegram Bot Token
BOT_TOKEN=your_bot_token_here
# 数据库连接
DATABASE_URL=postgresql://user:password@localhost:5432/mtphelper
# Ollama AI 服务
OLLAMA_BASE_URL=http://localhost:11434
创建数据库并运行初始化迁移
# 创建数据库
sudo -u postgres psql -c "CREATE DATABASE mtphelper;"
sudo -u postgres psql -c "CREATE USER mtphelper WITH PASSWORD 'your_password';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE mtphelper TO mtphelper;"
# 安装依赖
npm install
# 初始化数据库
npm run prisma:generate
npm run prisma:migrate
选择适合你的部署方式启动 SageGuard
npm run dev
# 编译项目
npm run build
# 使用 PM2 启动
npm install -g pm2
pm2 start ecosystem.config.js
pm2 save
pm2 startup
curl http://localhost:3000/health
应该返回服务状态信息
# PM2 日志
pm2 logs mtphelper
# 直接运行日志
# 查看控制台输出
确认没有错误信息
向你的机器人发送 /start 命令