Ubuntu/Debian 系统安装 OpenClaw 完整指南
# Ubuntu/Debian 系统安装 OpenClaw 完整指南
本教程详细介绍如何在 Ubuntu 20.04+ 或 Debian 11+ 系统上安装 OpenClaw AI 助手平台
环境要求
- Ubuntu 20.04+ 或 Debian 11+
- 2GB+ RAM
- 20GB+ 可用磁盘空间
- Node.js 18+
- PostgreSQL 14+ (可选,用于生产环境)
第一步:更新系统
bash
sudo apt update && sudo apt upgrade -y第二步:安装 Node.js
bash
# 安装 Node.js 20.x
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# 验证安装
node --version # 应该显示 v20.x.x
npm --version第三步:安装 PostgreSQL (可选)
bash
sudo apt install -y postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresql
# 创建数据库
sudo -u postgres createuser -s openclaw
sudo -u postgres createdb openclaw
sudo -u postgres psql -c "ALTER USER openclaw WITH PASSWORD 'your_password';"第四步:克隆并安装 OpenClaw
bash
# 克隆项目
git clone https://github.com/openclaw/openclaw.git
cd openclaw
# 安装依赖
npm install
# 复制环境配置
cp .env.example .env
# 编辑配置文件,设置数据库连接等
nano .env第五步:配置 .env 文件
env
DATABASE_URL=postgresql://openclaw:your_password@localhost:5432/openclaw
JWT_SECRET=your-secret-key-change-this
AI_PROVIDER=openai
OPENAI_API_KEY=your-api-key第六步:初始化数据库
bash
# 生成 Prisma 客户端
npx prisma generate
# 同步数据库结构
npx prisma db push
# 可选:填充种子数据
npx prisma db seed第七步:启动服务
bash
# 开发模式
npm run dev
# 或生产模式
npm run build
npm start第八步:使用 PM2 保持运行 (推荐)
bash
# 安装 PM2
sudo npm install -g pm2
# 启动应用
pm2 start npm --name "openclaw" -- start
# 设置开机自启
pm2 startup
pm2 save验证安装
浏览器访问 http://your-server-ip:3000 应该能看到 OpenClaw 界面。
常见问题
端口被占用
bash
# 查看端口占用
sudo lsof -i :3000
# 或修改 .env 中的 PORT数据库连接失败
检查 .env 中的 DATABASE_URL 是否正确,以及 PostgreSQL 服务是否运行。
---
下一篇文章:CentOS/RHEL 系统安装指南
相关文章
CentOS/RHEL 系统安装 OpenClaw 指南
# CentOS/RHEL 系统安装 OpenClaw 指南 > 本教程详细介绍如何在 CentOS Stream 9 或 RHEL 9 上安装 OpenClaw ## 环境要求 - CentO
2026-03-20Windows WSL2 安装 OpenClaw 教程
在 Windows 11/10 上通过 WSL2 Ubuntu 安装 OpenClaw 的详细教程,适合开发环境。
2026-03-20macOS 安装 OpenClaw 指南
# macOS 安装 OpenClaw 指南 > 在 Mac 上安装 OpenClaw AI 助手平台 ## 环境要求 - macOS 12 (Monterey) 或更高版本 - 4GB+ RA
2026-03-20