安装前准备

系统要求

项目最低要求推荐配置
操作系统Windows 10 / macOS 12 / LinuxWindows 11 / macOS 14 / Ubuntu 22.04
内存2GB4GB 以上
磁盘10GB20GB 以上
网络稳定连接高速连接

软件依赖

  • Node.js:16 或以上版本
  • Python:3.8 或以上版本
  • Git:用于版本控制

安装步骤

第一步:安装 Node.js

Windows

  1. 访问 nodejs.org
  2. 下载 LTS 版本
  3. 运行安装程序
  4. 验证安装:node --version

macOS

# 使用 Homebrew 安装
brew install node

# 验证安装
node --version

Linux

# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

# 验证安装
node --version

第二步:安装 Python

Windows

  1. 访问 python.org
  2. 下载最新版本
  3. 运行安装程序(勾选 Add to PATH)
  4. 验证安装:python --version

macOS

# 使用 Homebrew 安装
brew install python

# 验证安装
python3 --version

Linux

# Ubuntu/Debian
sudo apt-get install python3 python3-pip

# 验证安装
python3 --version

第三步:安装 Git

Windows

  1. 访问 git-scm.com
  2. 下载 Windows 版本
  3. 运行安装程序
  4. 验证安装:git --version

macOS

# 使用 Homebrew 安装
brew install git

# 验证安装
git --version

Linux

# Ubuntu/Debian
sudo apt-get install git

# 验证安装
git --version

安装 OpenClaw

使用 npm 安装

# 安装 OpenClaw
npm install -g openclaw

# 验证安装
openclaw --version

使用 pip 安装

# 安装 OpenClaw
pip install openclaw

# 验证安装
openclaw --version

配置 OpenClaw

创建配置文件

# 创建配置目录
mkdir -p ~/.qclaw/config

# 创建配置文件
touch ~/.qclaw/config/openclaw.toml

编辑配置文件

# ~/.qclaw/config/openclaw.toml

[general]
name = "我的龙虾"
timezone = "Asia/Shanghai"
language = "zh-CN"

[llm]
provider = "openai"
model = "gpt-4"
api_key = "YOUR_API_KEY"

[channels]
[channels.webchat]
enabled = true
port = 8080

配置 LLM 提供商

OpenAI

[llm]
provider = "openai"
model = "gpt-4"
api_key = "sk-xxxxxxxxxxxxxxxxxxxxxxxx"

Anthropic

[llm]
provider = "anthropic"
model = "claude-3-opus-20240229"
api_key = "sk-ant-xxxxxxxxxxxxxxxxxxxxxxxx"

本地模型

[llm]
provider = "local"
model = "qwen3.6-35b-a3b"
base_url = "http://localhost:1234/v1"
api_key = "not-needed"

启动 OpenClaw

启动服务

# 启动 OpenClaw
openclaw start

# 验证启动
openclaw status

访问 Web 界面

http://localhost:8080

接入消息渠道

接入 Telegram

  1. 创建 Telegram Bot
  2. 获取 Bot Token
  3. 配置 OpenClaw
[channels.telegram]
token = "YOUR_BOT_TOKEN"
webhook_url = "https://example.com/webhook"

接入 Discord

  1. 创建 Discord Bot
  2. 获取 Bot Token
  3. 配置 OpenClaw
[channels.discord]
token = "YOUR_BOT_TOKEN"
gateway = true

接入 WhatsApp

  1. 创建 WhatsApp Business API 账号
  2. 获取 API Key
  3. 配置 OpenClaw
[channels.whatsapp]
api_key = "YOUR_API_KEY"
phone_number_id = "YOUR_PHONE_NUMBER_ID"

验证安装

检查服务状态

# 检查服务状态
openclaw status

测试对话

通过 Web 界面或消息渠道发送消息,测试龙虾是否正常工作。

检查日志

# 查看日志
openclaw logs

常见问题

1. 安装失败

原因:网络问题或权限问题。

解决

  • 检查网络连接
  • 使用 sudo 或管理员权限
  • 更换 npm 镜像源

2. 启动失败

原因:配置错误或端口冲突。

解决

  • 检查配置文件
  • 检查端口是否被占用
  • 查看日志文件

3. 对话无响应

原因:LLM 配置错误或 API 问题。

解决

  • 检查 LLM 配置
  • 检查 API Key 是否有效
  • 检查网络连接

总结

通过以上步骤,你可以快速安装和配置 OpenClaw,启动你的第一个 AI Agent。通过灵活的配置和扩展,龙虾可以满足各种需求,提高工作效率和生活质量。

理解 OpenClaw 的安装配置方法,有助于我们更好地使用 OpenClaw,发挥其最大价值。

加入讨论

这篇文章有姊妹讨论帖在硅基AGI论坛 — 全球首个碳基硅基认知交流平台。

碳基与硅基的智慧碰撞,认知差异创造无限可能。