在一台全新安装的 Ubuntu 24.04.4 LTS 上从头开始安装部署 OpenClaw 2026.3.8。

基础环境配置

首先需要将 APT 源更改为国内的镜像源。

备份原有配置
$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
写入阿里云镜像源
$ sudo tee /etc/apt/sources.list << 'EOF'
deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
EOF
更新缓存
$ sudo apt update
$ sudo apt upgrade -y
安装必要的工具

Ubuntu 采用基本安装,很多包没有选,这是几个在安装 OpenClaw 过程中需要使用到的工具,需要装上。

$ sudo apt install net-tools curl git

安装node.js

安装 Node.js 有两种方法,装完以后在使用上有些差异,推荐方法一。

方法一
# 下载和安装nvm:
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash

# 在当前终端会话激活nvm
$ \. "$HOME/.nvm/nvm.sh"

# 使用nvm安装Node.js:
$ nvm install 24

# 查看node版本:
$ node -v

# 查看npm版本:
$ npm -v
方法二
# 添加官方安装源:
$ curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -

# 查看是否有nodesource.sources安装源文件:
$ ls -al /etc/apt/sources.list.d

# apt 安装node.js:
$ sudo apt install nodejs

# 查看node版本:
$ node -v

# 查看npm版本:
$ npm -v
方法一与方法二差异对比
特性 NVM APT 官方源
安装位置 用户家目录 (~/.nvm) 系统目录 (/usr/bin/node)
权限要求 不需要 root/sudo 权限 需要 root/sudo 权限
多版本共存 支持(随时一键切换 18, 20, 24) 不支持(系统中只能存在一个版本)
npm 全局安装 直接运行,无需 sudo 经常需要 sudo npm install -g(易出权限问题)

推荐使用方法一安装node.js,安装openclaw过程中不会遇到权限报错,安装后的openclaw只有用户权限,安全性较高。

如果因网络原因无法访问 github,可用以下方法安装nvm:

# 从 gitee 镜像站克隆 nvm 代码:
$ git clone https://gitee.com/mirrors/nvm.git ~/.nvm
$ cd ~/.nvm
$ git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`

# 手动将以下内容加入 ~/.bashrc 或 ~/.zshrc:
$ export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# 修改 node 安装镜像源:
$ export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node

# 使用nvm安装Node.js:
$ nvm install 24

# 查看node版本:
$ node -v

# 查看npm版本:
$ npm -v

node.js 安装完成后需修改 npm 的镜像源:

# 查询当前使用的镜像源
$ npm get registry:

# 设置为阿里镜像源:
$ npm config set registry https://registry.npmmirror.com/

# 如果需要还原为官方镜像源,执行如下命令:
$ npm config set registry https://registry.npmjs.org/

安装和配置 OpenClaw

安装 openclaw 以及常用组件
$ npm install -g openclaw
$ npm install -g clawhub
$ npm install -g agent-browser

安装过程如果遇到访问 github 相关网站的报错,可以将主机的 DNS 改为 8.8.8.8。

交互式初始化 OpenClaw
$ openclaw onboard

🦞 OpenClaw 2026.3.8 (3caab92) — Say "stop" and I'll stop—say "ship" and we'll both learn a lesson.

▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░██
██░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░██
██░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
                  🦞 OPENCLAW 🦞                    
 
┌  OpenClaw onboarding
│
◇  Security ─────────────────────────────────────────────────────────────────────────────────╮
│                                                                                            │
│  Security warning — please read.                                                           │
│                                                                                            │
│  OpenClaw is a hobby project and still in beta. Expect sharp edges.                        │
│  By default, OpenClaw is a personal agent: one trusted operator boundary.                  │
│  This bot can read files and run actions if tools are enabled.                             │
│  A bad prompt can trick it into doing unsafe things.                                       │
│                                                                                            │
│  OpenClaw is not a hostile multi-tenant boundary by default.                               │
│  If multiple users can message one tool-enabled agent, they share that delegated tool      │
│  authority.                                                                                │
│                                                                                            │
│  If you’re not comfortable with security hardening and access control, don’t run           │
│  OpenClaw.                                                                                 │
│  Ask someone experienced to help before enabling tools or exposing it to the internet.     │
│                                                                                            │
│  Recommended baseline:                                                                     │
│  - Pairing/allowlists + mention gating.                                                    │
│  - Multi-user/shared inbox: split trust boundaries (separate gateway/credentials, ideally  │
│    separate OS users/hosts).                                                               │
│  - Sandbox + least-privilege tools.                                                        │
│  - Shared inboxes: isolate DM sessions (`session.dmScope: per-channel-peer`) and keep      │
│    tool access minimal.                                                                    │
│  - Keep secrets out of the agent’s reachable filesystem.                                   │
│  - Use the strongest available model for any bot with tools or untrusted inboxes.          │
│                                                                                            │
│  Run regularly:                                                                            │
│  openclaw security audit --deep                                                            │
│  openclaw security audit --fix                                                             │
│                                                                                            │
│  Must read: https://docs.openclaw.ai/gateway/security                                      │
│                                                                                            │
├────────────────────────────────────────────────────────────────────────────────────────────╯
│
◆  I understand this is personal-by-default and shared/multi-user use requires lock-down. Continue?
│  ● Yes / ○ No  

#用方向键选择 Yes

◆  Onboarding mode
│  ● QuickStart (Configure details later via openclaw configure.)  
│  ○ Manual

#选择快速安装,其它配置项安装后可以修改

◇  QuickStart ─────────────────────────╮
│                                      │
│  Gateway port: 18789                 │
│  Gateway bind: Loopback (127.0.0.1)  │
│  Gateway auth: Token (default)       │
│  Tailscale exposure: Off             │
│  Direct to chat channels.            │
│                                      │
├──────────────────────────────────────╯
│
◆  Model/auth provider
│  ○ OpenAI (Codex OAuth + API key)
│  ○ Anthropic
│  ○ Chutes
│  ○ vLLM
│  ○ MiniMax
│  ○ Moonshot AI (Kimi K2.5)
│  ○ Google
│  ○ xAI (Grok)
│  ○ Mistral AI
│  ○ Volcano Engine
│  ○ BytePlus
│  ○ OpenRouter
│  ○ Kilo Gateway
│  ○ Qwen
│  ○ Z.AI
│  ○ Qianfan
│  ○ Copilot
│  ○ Vercel AI Gateway
│  ○ OpenCode Zen
│  ○ Xiaomi
│  ○ Synthetic
│  ○ Together AI
│  ○ Hugging Face
│  ○ Venice AI
│  ○ LiteLLM
│  ○ Cloudflare AI Gateway
│  ● Custom Provider
│  ○ Skip for now 
└ 

#用方向键选择要用的大模型供应商,如果列表里没有,如Deepseek,可以选择 Custom Provider

◆  API Base URL
│  https://api.deepseek.com
# 输入 deepseek 的 Base URL
◆  How do you want to provide this API key?
│  ● Paste API key now (Stores the key directly in OpenClaw config)
│  ○ Use external secret provider
└

#选择使用 API Key

◆  API Key (leave blank if not required)
│  sk-xxxxxxxx

#输入在 deepseek 官网创建的 API Key

◆  Endpoint compatibility
│  ● OpenAI-compatible (Uses /chat/completions)
│  ○ Anthropic-compatible
│  ○ Unknown (detect automatically)

#选择 OpenAI 兼容模式

◆  Model ID
│  deepseek-chat

#模型 ID 输入 deepseek-chat

◆  Endpoint ID
│  custom-api-deepseek-com

#端点ID,默认回车即可

◆  Model alias (optional)

#模型描述,可选项,回车即可

◆  Select channel (QuickStart)
│  ○ Telegram (Bot API)
│  ○ WhatsApp (QR link)
│  ○ Discord (Bot API)
│  ○ IRC (Server + Nick)
│  ○ Google Chat (Chat API)
│  ○ Slack (Socket Mode)
│  ○ Signal (signal-cli)
│  ○ iMessage (imsg)
│  ○ LINE (Messaging API)
│  ○ Feishu/Lark (飞书)
│  ○ Nostr (NIP-04 DMs)
│  ○ Microsoft Teams (Bot Framework)
│  ○ Mattermost (plugin)
│  ○ Nextcloud Talk (self-hosted)
│  ○ Matrix (plugin)
│  ○ BlueBubbles (macOS app)
│  ○ Zalo (Bot API)
│  ○ Zalo (Personal Account)
│  ○ Synology Chat (Webhook)
│  ○ Tlon (Urbit)
│  ● Skip for now (You can add channels later via `openclaw channels add`)

#配置通讯软件,可以先跳过,模型通了以后可以让它自己配置

◆  Search provider
│  ○ Brave Search (Structured results · country/language/time filters)
│  ○ Gemini (Google Search)
│  ○ Grok (xAI)
│  ○ Kimi (Moonshot)
│  ○ Perplexity Search
│  ● Skip for now

#配置搜索引擎,也先跳过,模型通了以后可以让它自己配置,有些工具还需要注册并提交 API-Key

◆  Configure skills now? (recommended)
│  ○ Yes / ● No

#skill 也不不装,后面用啥让它自己装

◇  Set GOOGLE_PLACES_API_KEY for goplaces?
│  No
│
◇  Set GEMINI_API_KEY for nano-banana-pro?
│  No
│
◇  Set NOTION_API_KEY for notion?
│  No
│
◇  Set OPENAI_API_KEY for openai-image-gen?
│  No
│
◇  Set OPENAI_API_KEY for openai-whisper-api?
│  No
│
◇  Set ELEVENLABS_API_KEY for sag?
│  No

#上面几个也先选 no,网络原因,配了也很难用

◆  Enable hooks?
│  ◻ Skip for now
│  ◼ 🚀 boot-md (Run BOOT.md on gateway startup)
│  ◼ 📎 bootstrap-extra-files (Inject additional workspace bootstrap files via glob/path patterns)
│  ◼ 📝 command-logger (Log all command events to a centralized audit file)
│  ◼ 💾 session-memory (Save session context to memory when /new or /reset command is issued)
└

#这几个 hooks 都启用

◆  How do you want to hatch your bot?
│  ○ Hatch in TUI (recommended)
│  ● Open the Web UI
│  ○ Do this later

#选择 Web UI

◇  Dashboard ready ────────────────────────────────────────────────────────────────╮
│                                                                                  │
│  Dashboard link (with token):                                                    │
│  http://127.0.0.1:18789/#token=52e7cff45e3b9b1193d1b76343f6863b551d14d1adb22305  │
│  Copy/paste this URL in a browser on this machine to control OpenClaw.           │
│  No GUI detected. Open from your computer:                                       │
│  ssh -N -L 18789:127.0.0.1:18789 user@192.168.88.135                             │
│  Then open:                                                                      │
│  http://localhost:18789/                                                         │
│  http://localhost:18789/#token=52e7cff45e3b9b1193d1b76343f6863b551d14d1adb22305  │
│  Docs:                                                                           │
│  https://docs.openclaw.ai/gateway/remote                                         │
│  https://docs.openclaw.ai/web/control-ui                                         │
│                                                                                  │
├──────────────────────────────────────────────────────────────────────────────────╯
│
◇  Workspace backup ────────────────────────────────────────╮
│                                                           │
│  Back up your agent workspace.                            │
│  Docs: https://docs.openclaw.ai/concepts/agent-workspace  │
│                                                           │
├───────────────────────────────────────────────────────────╯
│
◇  Security ──────────────────────────────────────────────────────╮
│                                                                 │
│  Running agents on your computer is risky — harden your setup:  │
│  https://docs.openclaw.ai/security                              │
│                                                                 │
├─────────────────────────────────────────────────────────────────╯
│
◇  Web search ───────────────────────────────────────╮
│                                                    │
│  Web search was skipped. You can enable it later:  │
│    openclaw configure --section web                │
│                                                    │
│  Docs: https://docs.openclaw.ai/tools/web          │
│                                                    │
├────────────────────────────────────────────────────╯
│
◇  What now ─────────────────────────────────────────────────────────────╮
│                                                                        │
│  What now: https://openclaw.ai/showcase ("What People Are Building").  │
│                                                                        │
├────────────────────────────────────────────────────────────────────────╯
│
└  Onboarding complete. Use the dashboard link above to control OpenClaw.

根据提示,用浏览器访问 http://127.0.0.1:18789/#token=52e7cff45e3b9b1193d1b76343f6863b551d14d1adb22305。

到此,你的 OpenClaw 可以正常始用了,记得先互相认识一下。

Logo

小龙虾开发者社区是 CSDN 旗下专注 OpenClaw 生态的官方阵地,聚焦技能开发、插件实践与部署教程,为开发者提供可直接落地的方案、工具与交流平台,助力高效构建与落地 AI 应用

更多推荐