在 Ubuntu 上快速部署 OpenClaw 完整教程

在 Ubuntu 上快速部署 OpenClaw 完整教程

文章目录

在 Ubuntu 上部署 OpenClaw 完整教程

本文记录我在 Ubuntu 22.04 服务器上从零部署 OpenClaw 并接入飞书的完整过程,包括遇到的坑和解决方法。

环境信息

  • 系统: Ubuntu 22.04 LTS
  • 配置: 4核 8GB 内存,100M 带宽
  • 类型 CPU

一、安装依赖

1.1 更新系统包索引

sudoapt update 

1.2 安装 curl

sudoaptinstall-ycurl

1.3 通过 NodeSource 安装最新稳定 LTS 版本

# 添加 NodeSource 仓库并安装curl-fsSL https://deb.nodesource.com/setup_lts.x |sudo-Ebash - sudoapt-getinstall-y nodejs # 安装完成后,验证版本node-vnpm-v

实际输出:

ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$ node-v v24.14.0 ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$ npm-v11.9.0 

1.4 设置淘宝镜像(最常用)

npm config set registry https://registry.npmmirror.com # 查询是否配置成功npm config get registry 

验证输出:

ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$ npm config get registry https://registry.npmmirror.com 

二、安装 OpenClaw

执行安装脚本(注意:安装过程中要勾选 yes):

curl-fsSL https://openclaw.ai/install.sh |bash

完整安装日志:

 ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$ curl-fsSL https://openclaw.ai/install.sh |bash 🦞 OpenClaw Installer The only crab in your contacts you actually want to hear from. 🦞 ✓ Detected: linux Install plan OS: linux Install method: npm Requested version: latest [1/3] Preparing environment ✓ Node.js v24.14.0 found · Active Node.js: v24.14.0 (/usr/bin/node) · Active npm: 11.9.0 (/usr/bin/npm)[2/3] Installing OpenClaw ✓ Git already installed · Configuring npmfor user-local installs ✓ npm configured for user installs · Installing OpenClaw v2026.2.26 ✓ OpenClaw npm package installed ✓ OpenClaw installed [3/3] Finalizing setup !PATH missing npm global bin dir: /home/ubuntu/.npm-global/bin This can make openclaw show as "command not found"in new terminals. Fix (zsh: ~/.zshrc, bash: ~/.bashrc): exportPATH="/home/ubuntu/.npm-global/bin:$PATH" 🦞 OpenClaw installed successfully (2026.2.26)! All done! I promise to only judge your code a little bit. · Starting setup 🦞 OpenClaw 2026.2.26 (bc50708) — Ship fast, log faster. ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░██ ██░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░██ ██░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ 🦞 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 │ ◇ Onboarding mode │ QuickStart │ ◇ 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 │ Z.AI │ ◇ Z.AI auth method │ CN │ ◇ How do you want to provide this API key? │ Paste API key now │ ◇ Enter Z.AI API key │ xxx.xxxx │ ◇ Model configured ───────────────╮ │ │ │ Default model set to zai/glm-5 │ │ │ ├──────────────────────────────────╯ │ ◇ Default model │ zai/glm-4.7 │ ◇ Channel status ────────────────────────────╮ │ │ │ Telegram: needs token │ │ WhatsApp (default): not linked │ │ Discord: needs token │ │ Slack: needs tokens │ │ Signal: needs setup │ │ signal-cli: missing (signal-cli) │ │ iMessage: needs setup │ │ imsg: missing (imsg) │ │ IRC: not configured │ │ Google Chat: not configured │ │ Feishu: install plugin to enable │ │ Google Chat: install plugin to enable │ │ Nostr: install plugin to enable │ │ Microsoft Teams: install plugin to enable │ │ Mattermost: install plugin to enable │ │ Nextcloud Talk: install plugin to enable │ │ Matrix: install plugin to enable │ │ BlueBubbles: install plugin to enable │ │ LINE: install plugin to enable │ │ Zalo: install plugin to enable │ │ Zalo Personal: install plugin to enable │ │ Synology Chat: install plugin to enable │ │ Tlon: install plugin to enable │ │ │ ├─────────────────────────────────────────────╯ │ ◇ How channels work ───────────────────────────────────────────────────────────────────────╮ │ │ │ DM security: default is pairing; unknown DMs get a pairing code. │ │ Approve with: openclaw pairing approve <channel><code> │ │ Public DMs require dmPolicy="open" + allowFrom=["*"]. │ │ Multi-user DMs: run: openclaw config set session.dmScope "per-channel-peer"(or │ │ "per-account-channel-peer"for multi-account channels) to isolate sessions. │ │ Docs: channels/pairing │ │ │ │ Telegram: simplest way to get started — register a bot with @BotFather and get going. │ │ WhatsApp: works with your own number; recommend a separate phone + eSIM. │ │ Discord: very well supported right now. │ │ IRC: classic IRC networks with DM/channel routing and pairing controls. │ │ Google Chat: Google Workspace Chat app with HTTP webhook. │ │ Slack: supported (Socket Mode). │ │ Signal: signal-cli linked device;more setup (David Reagans: "Hop on Discord."). │ │ iMessage: this is still a work in progress. │ │ Feishu: 飞书/Lark enterprise messaging with doc/wiki/drive tools. │ │ Nostr: Decentralized protocol; encrypted DMs via NIP-04. │ │ Microsoft Teams: Bot Framework; enterprise support. │ │ Mattermost: self-hosted Slack-style chat;install the plugin to enable. │ │ Nextcloud Talk: Self-hosted chat via Nextcloud Talk webhook bots. │ │ Matrix: open protocol;install the plugin to enable. │ │ BlueBubbles: iMessage via the BlueBubbles mac app + REST API. │ │ LINE: LINE Messaging API bot for Japan/Taiwan/Thailand markets. │ │ Zalo: Vietnam-focused messaging platform with Bot API. │ │ Zalo Personal: Zalo personal account via QR code login. │ │ Synology Chat: Connect your Synology NAS Chat to OpenClaw with full agent capabilities. │ │ Tlon: decentralized messaging on Urbit;install the plugin to enable. │ │ │ ├───────────────────────────────────────────────────────────────────────────────────────────╯ │ ◇ Select channel (QuickStart) │ Skip for now Updated ~/.openclaw/openclaw.json Workspace OK: ~/.openclaw/workspace Sessions OK: ~/.openclaw/agents/main/sessions │ ◇ Skills status ─────────────╮ │ │ │ Eligible: 4 │ │ Missing requirements: 40 │ │ Unsupported on this OS: 7 │ │ Blocked by allowlist: 0 │ │ │ ├─────────────────────────────╯ │ ◇ Configure skills now? (recommended) │ No │ ◇ Hooks ──────────────────────────────────────────────────────────────────╮ │ │ │ Hooks let you automate actions when agent commands are issued. │ │ Example: Save session context to memory when you issue /new or /reset. │ │ │ │ Learn more: https://docs.openclaw.ai/automation/hooks │ │ │ ├──────────────────────────────────────────────────────────────────────────╯ │ ◇ Enable hooks? │ Skip for now Config overwrite: /home/ubuntu/.openclaw/openclaw.json (sha256 f763f7d577aba2ed75a863a91e3e9a116eab6ecc856e7731972988b006426453 -> 8eac9ee80087618bf88b5f7a2f1f6bdb4b5abf5dfa646c22bf65f64e92063204, backup=/home/ubuntu/.openclaw/openclaw.json.bak) │ ◇ Systemd ────────────────────────────────────────────────────────────────────────────────╮ │ │ │ Linux installs use a systemd user service by default. Without lingering, systemd stops │ │ the user session on logout/idle and kills the Gateway. │ │ Enabling lingering now (may require sudo; writes /var/lib/systemd/linger). │ │ │ ├──────────────────────────────────────────────────────────────────────────────────────────╯ │ ◇ Systemd ───────────────────────────────╮ │ │ │ Enabled systemd lingering for ubuntu. │ │ │ ├─────────────────────────────────────────╯ │ ◇ Gateway service runtime ────────────────────────────────────────────╮ │ │ │ QuickStart uses Node for the Gateway service(stable + supported). │ │ │ ├──────────────────────────────────────────────────────────────────────╯ │ ◐ Installing Gateway service… Installed systemd service: /home/ubuntu/.config/systemd/user/openclaw-gateway.service ◇ Gateway service installed. │ ◇ Agents: main (default) Heartbeat interval: 30m (main) Session store (main): /home/ubuntu/.openclaw/agents/main/sessions/sessions.json (0 entries) │ ◇ Optional apps ────────────────────────╮ │ │ │ Add nodes for extra features: │ │ - macOS app (system + notifications) │ │ - iOS app (camera/canvas) │ │ - Android app (camera/canvas) │ │ │ ├────────────────────────────────────────╯ │ ◇ Control UI ─────────────────────────────────────────────────────────────────────╮ │ │ │ Web UI: http://127.0.0.1:18789/ │ │ Web UI (with token): │ │ http://127.0.0.1:18789/#token=2962e8f5116c63d86ea9c8224bc8d6445cce2e806ed1e183 │ │ Gateway WS: ws://127.0.0.1:18789 │ │ Gateway: reachable │ │ Docs: https://docs.openclaw.ai/web/control-ui │ │ │ ├──────────────────────────────────────────────────────────────────────────────────╯ │ ◇ Start TUI (best option!) ─────────────────────────────────╮ │ │ │ This is the defining action that makes your agent you. │ │ Please take your time. │ │ The more you tell it, the better the experience will be. │ │ We will send: "Wake up, my friend!" │ │ │ ├────────────────────────────────────────────────────────────╯ │ ◇ Token ─────────────────────────────────────────────────────────────────────────────────╮ │ │ │ Gateway token: shared auth for the Gateway + Control UI. │ │ Stored in: ~/.openclaw/openclaw.json (gateway.auth.token) or OPENCLAW_GATEWAY_TOKEN. │ │ View token: openclaw config get gateway.auth.token │ │ Generate token: openclaw doctor --generate-gateway-token │ │ Web UI stores a copy in this browser's localStorage (openclaw.control.settings.v1). │ │ Open the dashboard anytime: openclaw dashboard --no-open │ │ If prompted: paste the token into Control UI settings (or use the tokenized dashboard │ │ URL). │ │ │ ├─────────────────────────────────────────────────────────────────────────────────────────╯ │ ◇ How do you want to hatch your bot? │ Open the Web UI │ ◇ Dashboard ready ────────────────────────────────────────────────────────────────╮ │ │ │ Dashboard link(with token): │ │ http://127.0.0.1:18789/#token=2962e8f5116c63d86ea9c8224bc8d6445cce2e806ed1e183 │ │ Copy/paste this URL in a browser on this machine to control OpenClaw. │ │ No GUI detected. Open from your computer: │ │ ssh-N-L18789:127.0.0.1:18789 [email protected] │ │ Then open: │ │ http://localhost:18789/ │ │ http://localhost:18789/#token=2962e8f5116c63d86ea9c8224bc8d6445cce2e806ed1e183 │ │ 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 │ │ │ ├─────────────────────────────────────────────────────────────────╯ │ ◇ Shell completion ────────────────────────────────────────────────────────╮ │ │ │ Shell completion installed. Restart your shell or run: source ~/.bashrc │ │ │ ├───────────────────────────────────────────────────────────────────────────╯ │ ◇ Web search (optional) ─────────────────────────────────────────────────────────────────╮ │ │ │ If you want your agent to be able to search the web, you’ll need an API key. │ │ │ │ OpenClaw uses Brave Search for the `web_search` tool. Without a Brave Search API key, │ │ web search won’t work. │ │ │ │ Set it up interactively: │ │ - Run: openclaw configure --section web │ │ - Enable web_search and paste your Brave Search API key │ │ │ │ Alternative: set BRAVE_API_KEY in the Gateway environment (no config changes). │ │ 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. ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$ 

三、解决 PATH 问题

安装完成后,如果执行 which openclaw 找不到命令,需要手动配置 PATH:

# 检查 openclaw 是否在 PATH 中which openclaw # 如果找不到,查看 npm 全局安装目录npm prefix -g# 查看当前 shellecho$SHELL# 如果输出 /bin/bash,使用 ~/.bashrc# 如果输出 /bin/zsh,使用 ~/.zshrc# 将 npm 全局 bin 目录添加到 PATHecho'export PATH="$(npm prefix -g)/bin:$PATH"'>> ~/.bashrc # 重新加载配置文件source ~/.bashrc # 验证添加是否成功echo$PATH|grepnpm

四、访问控制界面

4.1 本地ssh连接服务器

在本地电脑执行,按提示输入远程linux云主机密码即可:

ssh-N-L18789:127.0.0.1:18789 ubuntu@你的云主机IP 
在这里插入图片描述

4.2 访问openclaw web ui

携带部署过程中生成的Dashboard link在本地进行访问,如下图:

http://localhost:18789/#token=你的token
在这里插入图片描述

4.3 测试

  1. 询问背后模型,如下图告知是glm4.7,与配置的一致

给AI助手起名为“大衍AI”,如下图,可切换界面等待其生效

在这里插入图片描述


在这里插入图片描述

五、总结

本文详细记录了在 Ubuntu 22.04 服务器上从零部署 OpenClaw 的完整流程,包括:

  • 环境准备:Node.js LTS 安装与 npm 镜像配置
  • OpenClaw 安装:通过官方脚本一键安装,处理 PATH 配置问题
  • 初始化配置:QuickStart 模式、Z.AI 模型接入
  • 远程访问:通过 SSH 隧道访问 Web 控制界面进行问答

六、后续内容预告

OpenClaw 的功能远不止于此,接下来我将在博客和B站频道推出更多深度内容,包括:

  • 🔧 进阶配置:自定义 Skills 技能、Hooks 自动化、多 Agent 管理
  • 🔒 安全加固:生产环境部署、访问控制、审计日志配置
  • 🛠️ 插件开发:自定义飞书工具插件、接入企业内部系统
  • 🤖 模型调优:Prompt 工程、多模型切换、上下文管理
  • 📊 实战案例:搭建团队知识库助手、自动化工作流机器人

六、视频教程

如果您觉得文字教程不够直观,欢迎访问我的 B 站频道观看完整视频版部署教程:

👉 点击观看《Ubuntu 部署 OpenClaw 手把手教学》

视频中我会实时演示每一步操作,详细讲解配置选项的含义,并演示如何在飞书中与机器人进行交互。建议搭配本文一起食用,效果更佳!

Read more

基于知识图谱的电影推荐问答系统 | Python Django Neo4j Echarts 协同过滤 大数据 人工智能 毕业设计源码

基于知识图谱的电影推荐问答系统 | Python Django Neo4j Echarts 协同过滤 大数据 人工智能 毕业设计源码

博主介绍:✌全网粉丝10W+,前互联网大厂软件研发、集结硕博英豪成立工作室。专注于计算机相关专业项目实战6年之久,选择我们就是选择放心、选择安心毕业✌ > 🍅想要获取完整文章或者源码,或者代做,拉到文章底部即可与我联系了。🍅 点击查看作者主页,了解更多项目! 🍅感兴趣的可以先收藏起来,点赞、关注不迷路,大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,希望帮助同学们顺利毕业 。🍅 1、毕业设计:2026年计算机专业毕业设计选题汇总(建议收藏)✅ 2、大数据毕业设计:2026年选题大全 深度学习 python语言 JAVA语言 hadoop和spark(建议收藏)✅ 1、项目介绍 技术栈 以Python为核心开发语言,基于Django框架搭建系统架构,搭配Neo4j图形数据库、MySQL数据库实现数据存储,整合Echarts可视化工具、协同过滤推荐算法,结合HTML完成前端页面构建。 功能模块 * 电影知识图谱管理 * 电影问答交互 * 电影列表展示 * 个人信息查看 * 电影详情展示 * 用户注册登录 * 后台电影数据管理 项目介绍

By Ne0inhk
计算机毕业设计:Python电商数据可视化分析与销量预测系统 Flask Selenium 机器学习 商品数据采集分析可视化系统 hadoop Agent 算法优化(建议收藏)✅

计算机毕业设计:Python电商数据可视化分析与销量预测系统 Flask Selenium 机器学习 商品数据采集分析可视化系统 hadoop Agent 算法优化(建议收藏)✅

1、项目介绍 技术栈 Python语言、Flask框架、Selenium爬虫、多元线性回归机器学习模型、LayUI框架、Bootstrap、Echarts图表库、MySQL数据库、Pandas数据处理库 功能模块 · 商品数据可视化大屏 · 商品数据后台管理 · 定时爬虫数据采集 · 机器学习销量预测 · 用户注册登录 · 用户管理(管理员) · 后台管理导航 项目介绍 本系统是一套为应对电商领域数据更新缓慢及销量预测难题而研发的一体化数据分析与可视化平台。后端采用Flask框架,通过Selenium技术实现对淘宝商品数据的自动化定时采集,并利用Pandas工具对原始数据进行清洗与规范化处理后存入MySQL数据库。前端融合LayUI与Bootstrap框架,借助Echarts图表库构建可视化大屏,直观展示商品销量与价格分布等核心指标的变化趋势。系统内置基于多元线性回归的机器学习模型,利用历史销量及特征数据进行训练,能够对未来销量进行科学预测。该平台集可视化展示、数据管理、爬虫调度、销量预测与用户权限控制于一体,可为电商企业提供实时的数据洞察与智能决策支持。 2、项目界面

By Ne0inhk
猫头虎AI开源项目推荐:国产开源AI工具爱派(AiPy)|支持本地部署、Python Use自动化操作本地文件的AI办公神器

猫头虎AI开源项目推荐:国产开源AI工具爱派(AiPy)|支持本地部署、Python Use自动化操作本地文件的AI办公神器

猫头虎推荐:国产开源AI工具 爱派(AiPy)|支持本地部署、自动化操作本地文件的AI办公神器 随着AI大模型的迅猛发展,诸如Manus、OpenManus等产品的出现,一款安装即免费使用的AI办公助手成为当下的刚需,各行业正经历着前所未有的数字化转型。尤其对于数据工程师、数据分析师以及日常办公用户而言,如何更高效、更便捷地利用AI工具处理繁琐重复的任务,已成为迫切需要解决的问题。 本文将全面介绍一款领先的国产开源AI工具——爱派(AiPy),它不仅能帮助用户实现数据自动化处理,还能一键赋能AI控制本地文件处理,极大提升工作效率。 背景 作为数据工程师或分析师,你是否经常面对以下困扰? * 频繁处理各种格式的数据文件,包括 CSV、Excel、JSON、HTML、SQLite、Parquet 等; * 数据清洗、转换、聚合、排序、过滤、分析及可视化等工作反复重复,费时费力。 传统的数据处理流程通常十分繁琐: 1. 打开Python环境,输入如import pandas as pd等大量基础代码; 2. 在处理过程中产生许多临时文件;

By Ne0inhk
Python驱动Ksycopg2连接和使用Kingbase:国产数据库实战指南

Python驱动Ksycopg2连接和使用Kingbase:国产数据库实战指南

引言 在国产数据库蓬勃发展的今天,KingbaseES作为国产数据库的佼佼者,凭借其高兼容性、高性能和高安全性,在金融、政府、能源等关键领域得到了广泛应用。本文将介绍如何通过Python的ksycopg2驱动连接并操作Kingbase数据库,从基础连接到高级操作全面掌握这一技术栈。 KingbaseES 数据库【系列篇章】: No.文章地址(点击进入)1电科金仓KingbaseES数据库解析:国产数据库的崛起与技术创新2KingBase数据库迁移利器:KDTS工具深度解析与实战指南3KingBase数据库迁移利器:KDTS工具 MySQL数据迁移到KingbaseES实战4电科金仓KingbaseES V9数据库:国产数据库的自主创新与行业实践深度解析5KingbaseES客户端工具Ksql使用全指南:从安装到高级操作6Spring JDBC与KingbaseES深度集成:构建高性能国产数据库应用实战7深度解析:基于 ODBC连接 KingbaseES 数据库的完整操作与实践 一、ksycopg2驱动:连接Kingbase的桥梁 1.1 驱动架构深度剖析 ksyc

By Ne0inhk