這是一篇筆記文章,讓人可以快速以虛擬化環境建構一個以免費OS-Ubuntu為基底的養蝦環境,以最基礎的Hyper-V為範例,並提供指令SOP。
這邊只講到環境建立,不包含後續模型安裝的部分,有需要指定模型的,可以在蝦裝完後再拉。
建議以22.04作為基礎養蝦環境,另外不建議以目前私人使用的電腦直接拿來養蝦,因為蝦與AI模型都會給予相當程度的系統權限處理事務,拿個人在用的電腦來養蝦,無疑暴露個人資訊的可能性大增,資安風險很高。

至於最小安裝要求,建議以vCPU不少於4,RAM不小於8-16GB為基礎。至於實際上你想要預留多少硬碟空間,則是要看你需要下哪一種模型來用,要注意!地端的模型遠比雲端吃API Token要耗費更多硬體資源,例如:想嘗試Gemma 4。
*要記得在內容設定的部份把安全開機啟用並選擇Microsoft UEFI 憑證授權單位。

至於要裝純指令環境還是具有GUI介面的環境,實際上都可以看個人喜好,如果你想體驗Medol實際上如何移動滑鼠跟輸入命令的過程,可以考慮裝圖形介面來理解。
事前準備
Tip: 請先確認你的Ubuntu可以連接外網環境,且可以正常取的固定的IP。
更新、升級、安裝 SSH 與 Hyper-V 驅動
此一過程可能需要重開數次以處理版本與套件更新的問題
sudo apt update && sudo apt full-upgrade -y && \
sudo apt install openssh-server linux-image-virtual linux-tools-virtual linux-cloud-tools-virtual -y && \
sudo systemctl enable --now ssh && \
sudo ufw allow ssh && \
echo "System Update & SSH Setup Complete!"
安裝 curl 與基礎工具
# 更新軟體源並安裝 curl, Git 以及編譯工具
# Update repositories and install curl, Git, and build-essential
sudo apt update
sudo apt install curl git build-essential -y
# 確認安裝成功
# Verify installation
curl --version && git --version
接著安裝 Node.js 22 LTS
# 下載並設定 Node.js 22 儲存庫
# Download and setup Node.js 22 repository
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
# 安裝 Node.js
# Install Node.js
sudo apt install -y nodejs
# 確認 Node.js 版本 (目標 v22.x)
# Verify Node.js version (target v22.x)
node -v
檢查 Git 配置
既然您已經裝了 Git,建議順手設定一下,這對之後從 GitHub 拉取 OpenClaw 更新很有幫助
Bash
git config --global user.name "your-name"
git config --global user.email "[email protected]"
從官方正版網址 取得龍蝦
https://github.com/openclaw/openclaw
# 使用官方網址克隆
git clone https://github.com/openclaw/openclaw.git
進入專案並安裝相依套件
如果你確認環境為拉下的最新版龍蝦可以考慮不要安裝npm,直接安裝pnpm,可以跳到後續章節來處理pnpm安裝程序。
# 進入資料夾 (Enter the directory)
cd ~/openclaw
# 安裝 NPM 套件 (Install NPM packages)
# 提示:這一步看虛擬機效能和記憶體空間是否足夠大,如果空間太小可能會跑很久
npm install
安裝瀏覽器核心
OpenClaw 需要 Chromium 才能去幫您爬網頁、看股市資訊或執行自動化。請執行:
# 只安裝 Chromium 核心即可,節省空間
# Install just the Chromium engine to save space
npx playwright install chromium
# 第一步:把「預設範本」複製成「正式設定檔」
# Step 1: Copy the "default template" to a "formal config file"
cp .env.example .env
# 第二步:使用 nano 編輯器開啟它
# Step 2: Open it with the nano editor
nano .env
以模型使用Gemini為例:在 nano 編輯器裡要做什麼?
當您進入一個黑色背景、底部有一排選單的畫面時:
When the editor opens (black background with a menu at the bottom):
使用鍵盤方向鍵向下移動。
找到這一行:GOOGLE_GENERATIVE_AI_API_KEY=
把您剛才申請到的 Gemini API Key 貼在 = 後面。
存檔並離開 (Save & Exit): * 按 Ctrl + O (儲存)
按 Enter (確認檔名)
按 Ctrl + X (離開編輯器)
啟動指令
# 1. 確保防火牆已開啟
# Ensure the firewall is open
sudo ufw allow 3000
# 2. 啟動系統
# Launch the system
npm run dev
錯誤處理
> openclaw@2026.3.26 build
> pnpm canvas:a2ui:bundle && node scripts/tsdown-build.mjs && node scripts/runtime-postbuild.mjs && node scripts/build-stamp.mjs && pnpm build:plugin-sdk:dts && node --import tsx scripts/write-plugin-sdk-entry-dts.ts && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/copy-export-html-templates.ts && node --import tsx scripts/write-build-info.ts && node --import tsx scripts/write-cli-startup-metadata.ts && node --import tsx scripts/write-cli-compat.ts
sh: 1: pnpm: not found
pnpm 比 npm 更快、更節省空間,且在處理 Monorepo(單一核心多專案)結構時更穩定。OpenClaw 的開發者顯然選擇了它作為標準。
# 1. 全域安裝 pnpm
# Install pnpm globally
sudo npm install -g pnpm
# 2. 確認安裝成功 (應該會顯示版本號)
# Verify installation
pnpm -v
# 3. 為了確保萬無一失,建議改用 pnpm 重新安裝一次相依套件
# Use pnpm to re-install dependencies to sync with the lockfile
cd ~/openclaw
pnpm install
所以如果您裝的最新龍蝦,可以考慮不用安裝npm,直接安裝pnpm就可以。
接下來:正式啟動編譯
既然工具都齊全了,請依序執行以下指令。這次我們使用 pnpm 來驅動:
1. 執行專案編譯 | Execute Project Build
這一步會處理剛才報錯的那個長指令,將 TypeScript 轉化為執行檔:
pnpm run build2. 啟動開發伺服器 | Launch Dev Server
編譯成功後,執行啟動指令:
pnpm run dev跟龍蝦打招呼
----------------------------------------
wei@wei-Claw:~/openclaw$ pnpm run dev
> openclaw@2026.3.30 dev /home/wei/openclaw
> node scripts/run-node.mjs
🦞 OpenClaw 2026.3.30 (910134b)
I've read more man pages than any human should—so you don't have to.
Usage: openclaw [options] [command]
Options:
--container <name> Run the CLI inside a running Podman/Docker container
named <name> (default: env OPENCLAW_CONTAINER)
--dev Dev profile: isolate state under ~/.openclaw-dev, default
gateway port 19001, and shift derived ports
(browser/canvas)
-h, --help Display help for command
--log-level <level> Global log level override for file + console
(silent|fatal|error|warn|info|debug|trace)
--no-color Disable ANSI colors
--profile <name> Use a named profile (isolates
OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH under
~/.openclaw-<name>)
-V, --version output the version number
Commands:
Hint: commands suffixed with * have subcommands. Run <command> --help for details.
acp * Agent Control Protocol tools
agent Run one agent turn via the Gateway
agents * Manage isolated agents (workspaces, auth, routing)
approvals * Manage exec approvals (gateway or node host)
backup * Create and verify local backup archives for OpenClaw
state
browser Manage OpenClaw's dedicated browser (Chrome/Chromium)
channels * Manage connected chat channels (Telegram, Discord, etc.)
clawbot * Legacy clawbot command aliases
completion Generate shell completion script
config * Non-interactive config helpers
(get/set/unset/file/validate). Default: starts guided
setup.
configure Interactive configuration for credentials, channels,
gateway, and agent defaults
cron * Manage cron jobs via the Gateway scheduler
daemon * Gateway service (legacy alias)
dashboard Open the Control UI with your current token
devices * Device pairing + token management
directory * Lookup contact and group IDs (self, peers, groups) for
supported chat channels
dns * DNS helpers for wide-area discovery (Tailscale + CoreDNS)
docs Search the live OpenClaw docs
doctor Health checks + quick fixes for the gateway and channels
gateway * Run, inspect, and query the WebSocket Gateway
health Fetch health from the running gateway
help Display help for command
hooks * Manage internal agent hooks
logs Tail gateway file logs via RPC
mcp Manage OpenClaw MCP config and channel bridge
memory Search, inspect, and reindex memory files
message * Send, read, and manage messages
models * Discover, scan, and configure models
node * Run and manage the headless node host service
nodes * Manage gateway-owned node pairing and node commands
onboard Interactive onboarding for gateway, workspace, and skills
pairing * Secure DM pairing (approve inbound requests)
plugins * Manage OpenClaw plugins and extensions
qr Generate iOS pairing QR/setup code
reset Reset local config/state (keeps the CLI installed)
sandbox * Manage sandbox containers for agent isolation
secrets * Secrets runtime reload controls
security * Security tools and local config audits
sessions * List stored conversation sessions
setup Initialize local config and agent workspace
skills * List and inspect available skills
status Show channel health and recent session recipients
system * System events, heartbeat, and presence
tasks * Inspect durable background task state
tui Open a terminal UI connected to the Gateway
uninstall Uninstall the gateway service + local data (CLI remains)
update * Update OpenClaw and inspect update channel status
webhooks * Webhook helpers and integrations
Examples:
openclaw models --help
Show detailed help for the models command.
openclaw channels login --verbose
Link personal WhatsApp Web and show QR + connection logs.
openclaw message send --target +15555550123 --message "Hi" --json
Send via your web session and print JSON result.
openclaw gateway --port 18789
Run the WebSocket Gateway locally.
openclaw --dev gateway
Run a dev Gateway (isolated state/config) on ws://127.0.0.1:19001.
openclaw gateway --force
Kill anything bound to the default gateway port, then start it.
openclaw gateway ...
Gateway control via WebSocket.
openclaw agent --to +15555550123 --message "Run summary" --deliver
Talk directly to the agent using the Gateway; optionally send the WhatsApp reply.
openclaw message send --channel telegram --target @mychat --message "Hi"
Send via your Telegram bot.
Docs: docs.openclaw.ai/cli
ELIFECYCLE Command failed with exit code 1.
看到上面那一長串輸出,表示已經養蝦成功了。後續有需要任何模型,可以透過龍蝦來拉。
龍蝦會有一個自己的GUI Web介面,可以用來存取跟操作龍蝦:
http://192.168.1.XX:18789/#token=change-me-to-a-long-random-token
<Token-API-KEY>
這是一個強大的 CLI(命令列介面)工具。剛才出現 exit code 1 只是因為您直接執行了 pnpm run dev 而沒有帶入具體的指令,所以它只顯示了「說明選單(Help Menu)」就結束了。
這是養蝦系列文的第一篇。我們後續也會介紹以Open WebUI來設定Gemma 4的安裝過程。





















