【Agent】Ubuntu22.04安装部署Openclaw(养龙虾)图文教程及免费Token攻略

【Agent】Ubuntu22.04安装部署Openclaw(养龙虾)图文教程及免费Token攻略

1.安装Ubuntu22.04系统

安装部署Openclaw所需硬件基本配置如下:

可以参考虚拟机安装Ubuntu22.04系统安装系统。

2.配置网络源

安装好系统后,依次执行以下命令修改网络源:

bash 复制代码
# 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服务:

bash 复制代码
# 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

【AI工具】免费获取各类AI大模型APIKEY的使用教程,以硅基流动+Deepseek为例

我本次用的是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

1.执行openclaw gateway install安装 OpenClaw 系统服务()

2.执行openclaw gateway start启动网关服务

3.执行openclaw gateway enable设置开机自启

4.执行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 未设置

按以下步骤完成配置:

bash 复制代码
# 1.编辑配置文件
nano ~/.openclaw/openclaw.json
# 2.添加/修改 gateway.mode 字段(注意:记住这里的token配置,后面登录会用到)
{
  "gateway": {
    "port": 18789,
    "mode": "local"
    "auth": {
      // 这里只放认证相关字段,如 "token" 或 "password"
    }
  },
  // 其他配置...
}
# 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)

bash 复制代码
{
  "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": "sk-orxxxxxxxxxxxxxxxxxxxxxxxxxx替换为自己的apikey" 
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "openrouter/auto",
        "fallbacks": [
          "openrouter/stepfun/step-3.5-flash:free",
          "openrouter/qwen/qwen3-coder:free",
          "openrouter/z-ai/glm-4.5-air:free"
        ]
      },
      "models": {
        "openrouter/auto": {
          "alias": "OpenRouter"
        },
        "openrouter/stepfun/step-3.5-flash:free": {},
        "openrouter/qwen/qwen3-coder:free": {},
        "openrouter/z-ai/glm-4.5-air:free": {}
      },
      "compaction": {
        "mode": "safeguard"
      },
      "maxConcurrent": 4,
      "subagents": {
        "maxConcurrent": 8
      }
    },
    "list": [
      {
        "id": "main",
        "model": "openrouter/stepfun/step-3.5-flash:free"
      }
    ]
  },
  "messages": {
    "ackReactionScope": "group-mentions"
  },
  "commands": {
    "native": "auto",
    "nativeSkills": "auto",
    "restart": true,
    "ownerDisplay": "raw"
  },
  "gateway": {
    "port": 18789,
    "mode": "local",
    "auth": {
      "mode": "token",
      "token": "123456"
    }
  }
}

8.打开网页与龙虾交流

配置完成后即可打开网页与龙虾交流:

9.配置skills

未完待续

10.Openclaw实用案例

未完待续

相关推荐
rrrjqy13 小时前
深入浅出 RAG:基于 Spring AI 的文档分块 (Chunking) 策略详解与实战
java·人工智能·后端·spring
测试员周周13 小时前
【Hermes系列3】登录回归不用先搭平台:我用 Hermes 跑通拆解→脚本→报告(实战篇:提示词可复制)
人工智能
Deepoch13 小时前
VLA分布式协同中枢:Deepoc开发板激活采摘机器人集群智能
人工智能·科技·机器人·具身模型·deepoc·采摘
薛定猫AI13 小时前
【技术干货】自进化知识库 + AI 编码代理:从概念到落地实战(含完整代码示例)
人工智能
见行AGV机器人13 小时前
AGV 无线通信
人工智能·agv·非标定制agv·agv控制器
wangqiaowq13 小时前
DeepSpeed 是一个由微软开发的开源深度学习优化库
人工智能
devnullcoffee13 小时前
深度思维与AI工具重塑亚马逊选品:从评论数据挖掘到Agent工作流的工程实践
java·人工智能·数据挖掘·亚马逊运营·亚马逊 asin 数据采集·数据决策
用户51914958484513 小时前
InstaWP Connect 漏洞利用工具 (CVE-2024-2667)
人工智能·aigc
2601_9544345513 小时前
2026年电钢琴品牌专业深度测评:排名前五权威榜单发布
大数据·人工智能·python
V搜xhliang024613 小时前
AI大模型辅助临床医学科研应用、论文写作、数据分析与AI绘图学习
人工智能·学习·数据分析