OpenClaw 是目前增长最快的开源自主AI代理框架(GitHub主仓库:https://github.com/openclaw/openclaw),支持完全自托管、本地优先运行。它能通过Telegram、WhatsApp、Discord等渠道接收自然语言指令,真正执行文件操作、浏览器自动化、代码提交、邮件发送等任务。
本文针对Linux服务器/VPS/本地Ubuntu/Debian/Fedora用户,提供最完整、最实操的部署流程。目标:让你的OpenClaw在Linux上稳定24/7运行,作为个人/团队的“数字员工”。
更新系统 & 安装基础工具
sudo apt update && sudo apt upgrade -y # Ubuntu/Debian
# 或
sudo dnf update -y # Fedora
sudo apt install -y curl git build-essential ca-certificates
安装Node.js(强烈推荐官方方式安装 v22 LTS 或更高)
使用NodeSource官方源(最干净、最稳定):
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
# 验证
node --version # 应显示 v22.x.x
npm --version
推荐额外安装pnpm(OpenClaw官方构建常用):
npm install -g pnpm@latest
可选但强烈推荐:安装Ollama(本地模型)
如果想完全离线/低成本运行:
curl -fsSL https://ollama.com/install.sh | sh
ollama serve & # 后台启动
ollama pull qwen2.5:32b # 或 deepseek-coder-v2、llama3.1 等
官方一键安装脚本(https://openclaw.ai/install.sh)已适配Linux:
curl -fsSL https://openclaw.ai/install.sh | bash
安装完成后立即验证:
openclaw --version # 看到类似 2026.3.x 即成功
如果一键脚本失败(极少数网络/权限问题),手动安装:
npm install -g openclaw@latest
# 或用 pnpm(更推荐)
pnpm add -g openclaw@latest
openclaw onboard --install-daemon
向导会交互式询问:
向导完成后,Gateway会自动启动为systemd服务。
检查状态:
sudo systemctl status openclaw-gateway
openclaw gateway status
开机自启 & 重启管理
已由 --install-daemon 自动完成。如需手动:
sudo systemctl enable openclaw-gateway
sudo systemctl start openclaw-gateway
sudo systemctl restart openclaw-gateway
日志查看
openclaw logs # CLI查看
journalctl -u openclaw-gateway -f # systemd实时日志
端口 & 防火墙
默认Web Dashboard:http://你的IP:18789
Gateway WebSocket:通常不需外网暴露
防火墙示例(ufw):
sudo ufw allow 18789/tcp
sudo ufw reload
浏览器自动化依赖(Puppeteer/Playwright)
OpenClaw内置浏览器工具需安装Chromium:
sudo apt install -y chromium-browser fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libcups2 libdbus-1-3 libgdk-pixbuf2.0-0 libnspr4 libnss3 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxrandr2 xdg-utils
然后在onboarding或配置文件中指定chromium路径。
在绑定的Telegram发消息:
成功收到回复 → 部署完成!
官方文档:https://docs.openclaw.ai 社区:https://discord.gg/clawd 或 GitHub Discussions
现在,你的Linux服务器上已经运行着一个强大的、会干活的AI龙虾🦞。有问题随时在聊天界面问它,它会越来越懂你。