1.安装 Ubuntu22.04 系统
安装部署 Openclaw 所需硬件基本配置如下:

可以参考虚拟机安装 Ubuntu22.04 系统安装系统。
2.配置网络源
安装好系统后,依次执行以下命令修改网络源:
# 1.备份网络源配置文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# 2.修改网络源配置文件
sudo tee /etc/apt/sources.list <<-'EOF'
deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
EOF
# 3.导入 22.04 官方公钥(无弃用警告)
sudo curl -fsSL https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3B4FE6ACC0B21F32 | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/ubuntu-official.gpg
# 4.清理缓存并更新
sudo apt clean && sudo apt update
3.安装 ssh 服务支持远程部署(可不安装)
依次执行以下命令安装 ssh 服务:
# 1.安装 SSH 服务(必须装这个才能被其他设备远程连接)
sudo apt install openssh-server -y
# 2.立即启动 SSH 服务
sudo systemctl start ssh
# 3.设置开机自启(重启电脑也能用)
sudo systemctl enable ssh
# 4.查看 SSH 状态
sudo systemctl status ssh
4.获取 api-key
推荐使用 OpenRouter 的免费模型,如 openrouter/stepfun/step-3.5-flash:free、openrouter/qwen/qwen3-coder:free、openrouter/z-ai/glm-4.5-air:free 等。

5.安装配置 Openclaw
执行命令:curl -fsSL https://openclaw.ai/install.sh | bash
这个安装脚本会自动帮你搞定所有依赖(Node.js、Git……),然后直接进入交互式配置向导。

配置选择如下:


剩下的几个配置先跳过。


6.安装过程中的问题解决
执行 openclaw gateway status 检查 openclaw 状态为未启动。

修复步骤如下:
1.解决 Gateway service not installed
- 执行
openclaw gateway install安装 OpenClaw 系统服务。

- 执行
openclaw gateway start启动网关服务。 - 执行
openclaw gateway enable设置开机自启。 - 执行
openclaw gateway status查看网关状态。

2.解决 RPC probe: failed(Gateway start blocked: set gateway.mode=local (current: unset) or pass --allow-unconfigured.)
根据 openclaw gateway status 输出,服务本身已安装并显示正在运行,但关键的 RPC 连接失败,且端口 18789 并未真正监听。这与官方文档中'Gateway will not start or service installed but not running'一节描述的情况高度吻合。
执行 journalctl --user -u openclaw-gateway.service -n 50 --no-pager -f 可以看到详细的报错信息:

日志显示 gateway 启动被阻止,原因是 'Gateway start blocked: set gateway.mode=local (current: unset) or pass --allow-unconfigured.'。这意味着配置文件中的 gateway.mode 没有设置,导致启动被阻止。这与我们之前的分析一致,服务虽然 systemd 启动,但进程初始化失败退出(status 1),然后 systemd 不断重启(restart counter 增加)。日志中还提到 lsof failed,但这是次要的,核心是 mode 未设置。
按以下步骤完成配置:
# 1.编辑配置文件
nano ~/.openclaw/openclaw.json
# 2.添加/修改 gateway.mode 字段(注意:记住这里的 token 配置,后面登录会用到)
{
"gateway": {
"port": 18789,
"mode": "local",
"auth": {
"token": "your_token_here"
}
},
"other_config": "..."
}
# 3.保存文件并退出编辑器(nano 中按 Ctrl+O 保存,Ctrl+X 退出)。
# 4.重启 gateway 服务
systemctl --user restart openclaw-gateway
# 5.检查服务状态
openclaw gateway status


可以看到 Openclaw 正常启动了。
3.解决 unauthorized: gateway token mismatch (open the dashboard URL and paste the token in Control UI settings)
执行 openclaw dashboard --no-open 生成包含正确令牌的仪表盘 URL。

打开 url 地址,看到以下页面:

连接失败时,执行 nano ~/.openclaw/openclaw.json,将其中的 token 配置项的值复制到网关令牌中即可连接成功。

7.配置模型和 apikey
执行 nano ~/.openclaw/openclaw.json 编辑 openclaw 配置文件。可以参考以下配置(替换自己想用的模型和 apikey):
{
"meta": {"lastTouchedVersion": "2026.3.13", "lastTouchedAt": "2026-03-18T08:49:59.347Z"},
"wizard": {"lastRunAt": "2026-03-18T08:37:25.135Z", "lastRunVersion": "2026.3.13", "lastRunCommand": "configure", "lastRunMode": "local"},
"auth": {"profiles": {"openrouter:default": {"provider": "openrouter", "mode": "api_key"}}},
"env": {"OPENROUTER_API_KEY":
8.打开网页与龙虾交流
配置完成后即可打开网页与龙虾交流:




