🦞
零基础入门 OpenClaw入门

Windows 下主机直接安装龙虾 OpenClaw:图文教程

无需 Docker,直接在 Windows 主机上部署龙虾,充分发挥 AI Agent 本地控制能力

预计阅读 15 分钟 共 11 个步骤 28102 次阅读
# OpenClaw # Windows # Node.js # Git Bash # 主机安装 # 大模型配置 # 入门

教程简介

本教程介绍如何在 Windows 系统上直接安装龙虾(OpenClaw),无需 Docker 或 WSL 环境。直接部署的最大优势在于可直接访问和控制本机资源,包括文件系统、进程管理及本地软件调用,从而充分发挥 AI Agent 的能力。涵盖 Node.js 安装、Git Bash 配置、OpenClaw 源码编译、大模型参数配置及服务启动全流程。

1

下载并安装 Node.js

代码示例
node -v
npm -v
2

安装 pnpm 并配置镜像源

代码示例
npm install -g pnpm
pnpm -v
pnpm config set registry https://registry.npmmirror.com/
3

安装 Git Bash

4

下载 OpenClaw 源码

5

编译安装 OpenClaw

代码示例
pnpm install
pnpm ui:build
pnpm build
6

初始化配置

代码示例
openclaw setup
7

更新配置文件

代码示例
{
  "models": {
    "mode": "merge",
    "providers": {
      "custom-001": {
        "baseUrl": "xxxxx",
        "apiKey": "xxxxxx",
        "api": "openai-completions",
        "models": [
          {
            "id": "qwen-plus",
            "name": "qwen-plus (Custom Provider)",
            "reasoning": false,
            "input": [
              "text"
            ],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            }
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "custom-001/qwen-plus"
      },
      "models": {
        "custom-001/qwen-plus": {}
      },
      "workspace": "C:\\Users\\Administrator\\.openclaw\\workspace",
      "contextPruning": {
        "mode": "cache-ttl",
        "ttl": "1h"
      },
      "compaction": {
        "mode": "safeguard"
      },
      "heartbeat": {
        "every": "30m"
      }
    }
  },
  "tools": {
    "profile": "coding",
    "web": {
      "search": {
        "enabled": true,
        "provider": "gemini",
        "gemini": {
          "apiKey": "sk-xxxxxxxxxx"
        }
      }
    }
  },
  "commands": {
    "native": "auto",
    "nativeSkills": "auto",
    "restart": true,
    "ownerDisplay": "raw"
  },
  "session": {
    "dmScope": "per-channel-peer"
  },
  "hooks": {
    "internal": {
      "enabled": true,
      "entries": {
        "boot-md": {
          "enabled": true
        },
        "bootstrap-extra-files": {
          "enabled": true
        },
        "command-logger": {
          "enabled": true
        },
        "session-memory": {
          "enabled": true
        }
      }
    }
  },
  "gateway": {
    "port": 18789,
    "mode": "local",
    "bind": "loopback",
    "controlUi": {
      "allowedOrigins": [
        "http://localhost:18789"
      ]
    },
    "auth": {
      "mode": "token",
      "token": "f2f4f617fe7a38cde2449495204c053d18168dcbc6d8ab61"
    },
    "tailscale": {
      "mode": "off",
      "resetOnExit": false
    },
    "nodes": {
      "denyCommands": [
        "camera.snap",
        "camera.clip",
        "screen.record",
        "contacts.add",
        "calendar.add",
        "reminders.add",
        "sms.send"
      ]
    }
  },
  "skills": {
    "install": {
      "nodeManager": "npm"
    },
    "entries": {
      "goplaces": {
        "apiKey": "sk-xxxxxxxxxxxxxx"
      },
      "nano-banana-pro": {
        "apiKey": "sk-xxxxxxxxxxxxxxxxxxxxx"
      },
      "notion": {
        "apiKey": "sk-xxxxxxxxxxxxxxxxxxxx"
      },
      "openai-image-gen": {
        "apiKey": "sk-xxxxxxxxxxxxxxxxxxxxx"
      },
      "openai-whisper-api": {
        "apiKey": "sk-xxxxxxxxxxxxxxxxxxxx"
      },
      "sag": {
        "apiKey": "sk-xxxxxxxxxxxxxxxxxxxxx"
      }
    }
  }
}
8

启动龙虾(OpenClaw)

代码示例
# 方式一:前台运行(调试推荐)
# 日志会直接输出到终端,关闭窗口后服务会随之退出
openclaw gateway --port 18789 --verbose

# 方式二:后台运行(生产环境推荐)
# 使用 nohup 将服务运行在后台,日志输出到指定文件,方便后续排查问题
nohup openclaw gateway --port 18789 > /tmp/openclaw-gateway.log 2>&1 &
9

访问前端页面

10

获取 Token 并完成连接

11

聊天功能测试

返回教程列表
觉得有用?分享给更多朋友吧