OpenClaw 学习中心/教程目录/第 03 章

入门 阅读约 10 分钟 第 03 章 / 共 15 章

基础配置入门

了解配置文件结构,完成首次运行的基本设置

本章内容

  1. 配置文件位置
  2. 首次运行配置向导
  3. 验证安装

配置文件位置

OpenClaw 的配置文件位于 ~/.openclaw/openclaw.json。你可以直接编辑这个文件,或者通过 openclaw dashboard 的图形界面进行配置。

基础配置结构

{
  "gateway": {
    "port": 18789,
    "host": "127.0.0.1"
  },
  "models": {
    "default": "anthropic/claude-3-5-sonnet-20241022"
  },
  "channels": {
    "telegram": {
      "botToken": "你的 Telegram Bot Token"
    }
  },
  "agent": {
    "workspace": "~/openclaw-workspace",
    "permissions": ["read", "write", "execute", "network"]
  }
}

首次运行配置向导

运行 openclaw onboard 会启动交互式配置向导,引导你完成初始设置:

  1. 选择 AI 模型提供商(推荐国内用户选择 KIMI 或 aigocode)
  2. 输入 API Key(可以先跳过,后续在第 4、5 章详细配置)
  3. 选择消息渠道(推荐国内用户选飞书)
  4. 设置工作空间目录(默认 ~/openclaw-workspace 即可)
  5. 安装守护进程,让 OpenClaw 在后台持续运行

提示:配置向导中所有选项都可以后续修改,不用担心选错。先完成基本配置,跑通流程更重要。

验证安装

验证步骤

# 查看版本号
openclaw --version

# 运行诊断检查
openclaw doctor

# 查看网关状态
openclaw gateway status

# 打开控制面板(浏览器会自动打开)
openclaw dashboard

常见问题

问题原因解决方案
命令找不到 (command not found)npm 全局路径未加入 PATH运行 export PATH="$(npm prefix -g)/bin:$PATH"
端口冲突 (port 18789)端口被其他程序占用运行 openclaw gateway --port 19000
网关无法启动配置文件或依赖问题运行 openclaw doctor --fix 自动修复