
在一台全新的 Ubuntu 虚拟机上,首先要替换国内软件源以保证下载速度。
bashsudo cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak
使用 sed 命令一键把官方域名替换为阿里云域名:
bashsudo sed -i 's/cn.archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list.d/ubuntu.sources
sudo sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list.d/ubuntu.sources
换完源后,刷新系统仓库:
bashsudo apt update
如果没有公网 IP,强烈建议使用 Tailscale 打通局域网限制,方便随时随地访问控制台。
bashcurl -fsSL https://tailscale.com/install.sh | sh
tskey-... 替换为实际的专属 Auth Key)bashsudo tailscale up --authkey=tskey-au-xxxxxxxxxxxxx
100.x.x.x 专属内网 IP:bashtailscale ip -4
该脚本会自动拉取代码、配置 Node.js 环境并初始化工作空间:
bashcurl -sSL https://openclaw.ai/install.sh | bash
让系统识别刚刚安装的 openclaw 命令:
bashsource ~/.bashrc && source ~/.profile
由于后续需要安装各种插件,建议把 npm 的源换成国内镜像(淘宝/阿里云维护):
bashnpm config set registry https://registry.npmmirror.com
执行 nano ~/.openclaw/openclaw.json 打开配置文件,找到 bind 字段,进行如下修改:
json"bind": "lan"
为什么要改写成 lan? 因为在 OpenClaw 的新逻辑里,
lan模式会自动把服务绑定到所有网卡(等同于以前的0.0.0.0),这样通过 Tailscale 穿透进来的流量才能正常访问控制台。
修改后重启网关:
bashopenclaw gateway restart
如果配置了专属域名,需要将其加入白名单:
bashopenclaw config set gateway.controlUi.allowedOrigins '["https://chat.zym588.space"]'
执行完后,再次重启网关:
bashopenclaw gateway restart
在重启或者更换域名后访问网页控制台,往往会报错 gateway token mismatch(令牌不匹配)。这通常是因为浏览器缓存了旧的 Token。
操作步骤:
bashopenclaw dashboard --no-open
http://127.0.0.1:18789/#token=xxxxxx 的链接。#token= 后面那一长串字符复制下来。处理新设备拦截: 连接成功后如果被系统拦截并提示设备未授权,需回到终端执行:
bash# 1. 查看当前待审批的设备请求
openclaw devices list
# 2. 批准该设备接入(替换下方括号内为列表中实际显示的设备 ID)
openclaw devices approve [设备ID]
为了在手机微信上直接与 AI 对话,需要接入企业微信渠道。
bashopenclaw plugins install @wecom/wecom-openclaw-plugin
安装完成后启动网关:
bashopenclaw gateway start
bashopenclaw channels add
WeCom (企业微信)。finish。bashopenclaw pairing approve wecom [在此处填入自定义的设备名称]
千万不要在网页端 UI 进行自定义大模型的配置(容易触发 JSON 格式 Bug)。必须使用命令行的交互工具。
在终端执行:
bashopenclaw configure
根据屏幕提示依次选择:
Model (模型) 并回车继续。Custom Provider (Any OpenAI or Anthropic compatible endpoint)。OpenAI。接着按顺序填入以下参数:
https://maas-coding-api.cn-huabei-1.xf-yun.com/v2astron-code-latest一路回车保存,配置完成!
本文作者:小转圈
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!