OpenClaw本地化部署安装指南
openclaw本地化小白部署教程。
·
OpenClaw本地化部署安装指南
适用于全新安装的 Ubuntu 系统
目录
系统要求
- 操作系统: Ubuntu 22.04 LTS 或更新版本
- 内存: 至少 2GB RAM(推荐 4GB)
- 磁盘空间: 至少 5GB 可用空间
- 网络: 可访问互联网(用于下载依赖和模型 API)
前置条件安装
1. 更新系统
sudo apt update && sudo apt upgrade -y
2. 安装基础依赖
sudo apt install -y \
curl \
wget \
git \
build-essential \
python3 \
python3-pip \
ca-certificates \
gnupg \
lsb-release \
software-properties-common
3. 安装 Node.js
OpenClaw 需要 Node.js 20+,推荐使用 NodeSource 安装:
# 添加 NodeSource 仓库
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
# 安装 Node.js
sudo apt install -y nodejs
# 验证安装
node --version # 应显示 v20.x.x
npm --version # 应显示 10.x.x
4. 安装 Chrome/Chromium(可选但推荐)
用于浏览器自动化功能:
# 安装 Chromium
sudo apt install -y chromium-browser
# 或者安装 Google Chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt update
sudo apt install -y google-chrome-stable
5. 配置 npm 全局安装路径(可选)
避免使用 sudo 安装全局包:
# 创建本地 npm 目录
mkdir -p ~/.npm-global
# 配置 npm 使用新路径
npm config set prefix '~/.npm-global'
# 添加到 PATH
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
安装 OpenClaw
1. 全局安装 OpenClaw CLI
npm install -g openclaw
或者使用 npx(无需全局安装):
npx openclaw@latest
2. 验证安装
openclaw --version
应显示类似:2026.3.13
初始化配置
1. 运行配置向导
openclaw configure
按照提示完成以下配置:
选择运行模式
- local: 本地运行(推荐用于单机部署)
- remote: 远程服务器模式
配置 AI 模型
Moonshot (Kimi) 配置示例:
Provider: moonshot
API Key: 你的 Moonshot API Key
Base URL: https://api.moonshot.cn/v1
Model: kimi-k2.5
获取 Moonshot API Key:
- 访问 https://platform.moonshot.cn/
- 注册/登录账号
- 在控制台创建 API Key
OpenAI 配置示例:
Provider: openai
API Key: sk-...
Base URL: https://api.openai.com/v1
Model: gpt-4o
配置 Gateway
Port: 8080(或其他你喜欢的端口)
Bind: lan(监听所有网络接口,允许远程访问)
2. 检查配置
openclaw config file
这会显示配置文件路径,通常是 ~/.openclaw/openclaw.json
启动 Gateway 服务
方式一:使用 systemd 服务(推荐)
OpenClaw 会自动创建用户级 systemd 服务:
# 启动服务
systemctl --user start openclaw-gateway
# 设置开机自启
systemctl --user enable openclaw-gateway
# 查看状态
systemctl --user status openclaw-gateway
# 查看日志
journalctl --user -u openclaw-gateway -f
方式二:手动启动(调试使用)
openclaw gateway --port 8080
验证 Gateway 运行状态
openclaw gateway status
正常输出应包含:
Runtime: running
Dashboard: http://192.168.x.x:8080/
访问 Dashboard
本地访问
在服务器上打开浏览器访问:
http://localhost:8080/
远程访问
在同一网络的其他设备上访问:
http://<服务器IP>:8080/
例如:http://192.168.1.16:8080/
首次访问时需要输入 Token,可以在配置文件中查看:
grep -A 2 '"auth"' ~/.openclaw/openclaw.json
配置远程访问
1. 修改配置允许远程访问
编辑配置文件:
nano ~/.openclaw/openclaw.json
确保以下配置:
{
"gateway": {
"port": 8080,
"bind": "lan",
"mode": "local",
"controlUi": {
"allowedOrigins": [
"http://localhost:8080",
"http://127.0.0.1:8080",
"http://192.168.1.16:8080"
],
"allowInsecureAuth": true
}
}
}
注意:将 192.168.1.16 替换为你的实际服务器 IP。
2. 防火墙配置
如果使用 UFW 防火墙:
# 允许 8080 端口
sudo ufw allow 8080/tcp
# 或者允许特定 IP
sudo ufw allow from 192.168.1.0/24 to any port 8080
# 重新加载防火墙
sudo ufw reload
3. 重启服务生效
systemctl --user restart openclaw-gateway
配置聊天频道(可选)
Telegram 机器人
# 启动 Telegram 配置
openclaw channels login --channel telegram
按照提示:
- 访问 @BotFather 创建机器人
- 获取 Bot Token
- 设置 Webhook 或轮询模式
openclaw channels login --channel whatsapp
常见问题
Q1: 安装时提示权限错误
问题:EACCES: permission denied
解决:
# 方法1:使用 npx
npx openclaw@latest
# 方法2:修复 npm 权限
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install -g openclaw
Q2: Gateway 启动失败
问题:Port already in use
解决:
# 查找占用端口的进程
sudo lsof -i :8080
# 杀掉进程或更换端口
openclaw config set gateway.port 8081
Q3: Dashboard 显示 “Origin not allowed”
解决:
- 编辑
~/.openclaw/openclaw.json - 在
gateway.controlUi.allowedOrigins中添加你的访问地址 - 重启服务
Q4: 远程无法访问 Dashboard
检查清单:
- ✅
gateway.bind设置为"lan"或"0.0.0.0" - ✅ 防火墙允许端口访问
- ✅
allowedOrigins包含正确的 IP 和端口 - ✅ 服务已重启
Q5: 如何更新 OpenClaw
npm update -g openclaw
# 或重新安装
npm install -g openclaw@latest
Q6: 如何完全卸载
# 停止服务
systemctl --user stop openclaw-gateway
systemctl --user disable openclaw-gateway
# 卸载 CLI
npm uninstall -g openclaw
# 删除配置和数据(谨慎操作)
rm -rf ~/.openclaw
下一步
安装完成后,你可以:
- 使用 TUI 界面:
openclaw tui - 查看帮助:
openclaw --help - 阅读文档:
openclaw docs - 运行健康检查:
openclaw doctor
参考链接
- 官方文档:https://docs.openclaw.ai
- GitHub:https://github.com/openclaw/openclaw
- 社区 Discord:https://discord.com/invite/clawd
希望这篇教程能帮到想要上手 OpenClaw 的朋友,要是觉得内容不错,不妨支持转发一下~
大家如果有任何问题,都可以加入 OpenClaw 交流群探讨提问,后续我会在群里更方便地分享更多好玩的 AI 工具,企业微信和 QQ 的对接教程做好后,也会第一时间在群里同步。加群时请备注:OpenClaw 交流群。

openclaw版本:2026.3.13
更多推荐




所有评论(0)