在 macOS VM 上運行 OpenClaw (使用 Lume 沙盒)
身為開發者,你一定遇過這種糾結:想測試一個新工具,但又不想把自己的主機環境搞得亂七八糟。或者更常見的情況是,你需要某些特定作業系統才有的功能(像是 iMessage),但你的伺服器全是 Linux。
這就是為什麼我們推薦在 macOS VM(虛擬機器)中執行 OpenClaw。透過沙盒隔離,你可以隨時重置環境,還能解鎖那些在 Linux 或 Windows 上玩不到的專屬功能。
需要準備的東西
Section titled “需要準備的東西”如果你選擇使用 Lume 在本地執行,你需要準備:
- Apple Silicon Mac (M1/M2/M3/M4)
- 宿主機需為 macOS Sequoia 或更高版本
- 每個 VM 約需 60 GB 的剩餘磁碟空間
- 大約 20 分鐘的時間
如果你是經驗豐富的老手,這就是你的快速路徑:
- 安裝 Lume。
- 執行
lume create openclaw --os macos --ipsw latest。 - 完成設定助理並開啟 Remote Login (SSH)。
- 執行
lume run openclaw --no-display。 - SSH 進去安裝 OpenClaw 並設定 channel。
- 完成。
為什麼要用 macOS VM?
Section titled “為什麼要用 macOS VM?”對於大多數用戶,我們建議將 Gateway 放在便宜的 Linux VPS 上。但如果你有以下需求,macOS VM 是最佳選擇:
- iMessage 支援: 透過 BlueBubbles 整合,這是 Linux 做不到的。
- 環境隔離: 保持你主要工作環境的乾淨。
- 快速重置: 透過複製 VM,你可以秒速還原到乾淨狀態。
你也可以選擇雲端供應商(如 MacStadium),只要拿到 SSH 存取權限,後續步驟都一樣。
1. 安裝 Lume
Section titled “1. 安裝 Lume”在你的 Mac 終端機執行:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)"如果 ~/.local/bin 不在你的 PATH 中,請加入它:
echo 'export PATH="$PATH:$HOME/.local/bin"' >> ~/.zshrc && source ~/.zshrc驗證安裝是否成功:
lume --version2. 建立 macOS VM
Section titled “2. 建立 macOS VM”lume create openclaw --os macos --ipsw latest這會下載 macOS 並建立 VM。完成後會自動打開一個 VNC 視窗。注意,下載時間取決於你的網速。
3. 完成設定助理
Section titled “3. 完成設定助理”在 VNC 視窗中:
- 選擇語言與地區。
- 跳過 Apple ID(如果你之後要用 iMessage,也可以現在登入)。
- 建立使用者帳號(請記住你的帳號密碼)。
- 跳過所有選配功能。
設定完成後,開啟 SSH:
- 打開 System Settings → General → Sharing。
- 開啟 Remote Login。
4. 取得 VM 的 IP 位址
Section titled “4. 取得 VM 的 IP 位址”在你的主機終端機輸入:
lume get openclaw找到 IP 位址(通常是 192.168.64.x)。
5. SSH 進入 VM
Section titled “5. SSH 進入 VM”ssh youruser@192.168.64.X把 youruser 換成你剛建立的帳號,IP 換成你 VM 的 IP。
6. 安裝 OpenClaw
Section titled “6. 安裝 OpenClaw”在 VM 裡面執行:
npm install -g openclaw@latestopenclaw onboard --install-daemon按照提示設定你的模型供應商(如 Anthropic 或 OpenAI)。
7. 設定 Channels
Section titled “7. 設定 Channels”編輯設定檔:
nano ~/.openclaw/openclaw.json加入你的 channel 設定,例如:
{ "channels": { "whatsapp": { "dmPolicy": "allowlist", "allowFrom": ["+15551234567"] }, "telegram": { "botToken": "YOUR_BOT_TOKEN" } }}接著登入 WhatsApp(掃描 QR code):
openclaw channels login8. 以無介面模式執行 VM
Section titled “8. 以無介面模式執行 VM”停止 VM 並以無介面模式重啟:
lume stop openclawlume run openclaw --no-display現在 VM 會在背景執行,OpenClaw 的 daemon 會確保 Gateway 持續運作。你可以隨時檢查狀態:
ssh youruser@192.168.64.X "openclaw status"加碼功能:iMessage 整合
Section titled “加碼功能:iMessage 整合”這是跑在 macOS 上的殺手鐧。你可以配合 BlueBubbles 把 iMessage 接入 OpenClaw。
在 VM 內:
- 從官網下載並安裝 BlueBubbles。
- 登入 Apple ID 並啟用 Web API,設定一個密碼。
- 將 BlueBubbles 的 webhook 指向你的 Gateway(例如:
https://your-gateway-host:3000/bluebubbles-webhook?password=<password>)。
在 OpenClaw 設定中加入:
{ "channels": { "bluebubbles": { "serverUrl": "http://localhost:1234", "password": "your-api-password", "webhookPath": "/bluebubbles-webhook" } }}重啟 Gateway 後,你的 AI Agent 就能收發 iMessage 了。
備份你的「黃金鏡像」
Section titled “備份你的「黃金鏡像」”在進行更多自定義之前,建議先備份一個乾淨的狀態:
lume stop openclawlume clone openclaw openclaw-golden如果之後想重來,隨時可以還原:
lume stop openclaw && lume delete openclawlume clone openclaw-golden openclawlume run openclaw --no-display| 問題 | 解決方案 |
|---|---|
| 無法 SSH 進入 VM | 檢查 VM 的 System Settings 中是否開啟了「Remote Login」 |
| 沒看到 VM 的 IP | 等 VM 完全啟動後,再次執行 lume get openclaw |
| 找不到 Lume 指令 | 確保已將 ~/.local/bin 加入你的 PATH |
| WhatsApp QR 無法掃描 | 執行 openclaw channels login 時,請確保你是登入在 VM 內而非主機 |
想了解更多自動化設定?請諮詢我們的 AI Setup Assistant。
OpenClaw Expert
還是卡住了?
如果這篇文件沒有解決你的情境,直接問 OpenClaw Expert,拿到可執行步驟。