Windows (WSL2)
透過 WSL2 在 Windows 上安裝與設定 OpenClaw 的指南,建議使用 Ubuntu 以獲得最佳 CLI 與 Gateway 相容性。
建議在 Windows 上透過 WSL2 使用 OpenClaw(推薦 Ubuntu)。CLI + Gateway 在 Linux 內部執行,保持執行環境一致性,使工具鏈更加相容(Node/Bun/pnpm、Linux 二進位檔、技能)。原生 Windows 可能較為棘手。WSL2 提供完整的 Linux 體驗——只需一個指令即可安裝:wsl --install。
原生 Windows 配套應用程式正在規劃中。
安裝(WSL2)
- 入門指南(在 WSL 內使用)
- 安裝與更新
- 官方 WSL2 指南(Microsoft):https://learn.microsoft.com/windows/wsl/install
Gateway
Gateway 服務安裝(CLI)
在 WSL2 內:
openclaw onboard --install-daemon
或:
openclaw gateway install
或:
openclaw configure
出現提示時選擇 Gateway service。
修復/遷移:
openclaw doctor
進階:透過 LAN 公開 WSL 服務(portproxy)
WSL 擁有自己的虛擬網路。如果其他機器需要連接到 WSL 內部 執行的服務(SSH、本機 TTS 伺服器或 Gateway),您必須將 Windows 連接埠轉發到目前的 WSL IP。WSL IP 在重新啟動後會改變,因此您可能需要重新整理轉發規則。
範例(以系統管理員身分開啟 PowerShell):
$Distro = "Ubuntu-24.04"
$ListenPort = 2222
$TargetPort = 22
$WslIp = (wsl -d $Distro -- hostname -I).Trim().Split(" ")[0]
if (-not $WslIp) { throw "WSL IP not found." }
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=$ListenPort `
connectaddress=$WslIp connectport=$TargetPort
允許連接埠通過 Windows 防火牆(僅需一次):
New-NetFirewallRule -DisplayName "WSL SSH $ListenPort" -Direction Inbound `
-Protocol TCP -LocalPort $ListenPort -Action Allow
WSL 重新啟動後重新整理 portproxy:
netsh interface portproxy delete v4tov4 listenport=$ListenPort listenaddress=0.0.0.0 | Out-Null
netsh interface portproxy add v4tov4 listenport=$ListenPort listenaddress=0.0.0.0 `
connectaddress=$WslIp connectport=$TargetPort | Out-Null
注意事項:
- 從其他機器 SSH 連線時,目標為 Windows 主機 IP(例如:
ssh user@windows-host -p 2222)。 - 遠端節點必須指向可連線的 Gateway URL(非
127.0.0.1);使用openclaw status --all確認。 - 使用
listenaddress=0.0.0.0以允許 LAN 存取;127.0.0.1僅限本機。 - 如果需要自動化,可註冊排程工作在登入時執行重新整理步驟。
逐步 WSL2 安裝
1) 安裝 WSL2 + Ubuntu
開啟 PowerShell(系統管理員):
wsl --install
# 或明確選擇發行版:
wsl --list --online
wsl --install -d Ubuntu-24.04
如果 Windows 要求,請重新開機。
2) 啟用 systemd(Gateway 安裝所需)
在您的 WSL 終端機中:
sudo tee /etc/wsl.conf >/dev/null <<'EOF'
[boot]
systemd=true
EOF
然後從 PowerShell:
wsl --shutdown
重新開啟 Ubuntu,然後驗證:
systemctl --user status
3) 安裝 OpenClaw(在 WSL 內)
在 WSL 內依照 Linux 入門流程:
git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
pnpm ui:build # 首次執行時自動安裝 UI 依賴
pnpm build
openclaw onboard
完整指南:入門指南
Windows 配套應用程式
目前尚無 Windows 配套應用程式。歡迎社群貢獻。