windows安装openclaw
安装
第一步:安装 WSL2 和 Ubuntu
以管理员身份打开 PowerShell,执行:
wsl --set-default-version 2
- Windows 11 默认已安装 WSL2,不需要执行该命令。
- Windows 10 用户 需要执行此命令,否则默认使用 WSL1。
安装linux系统(推荐 Ubuntu 24.04):
# 查看可用发行版
wsl --list --online
# 安装指定版本
wsl --install -d Ubuntu
如果 Windows 提示需要重启,请重启计算机以完成 WSL2 安装。
第二部:一键安装 OpenClaw
在 Ubuntu 终端中,运行官方一键安装脚本(它将自动检测并安装 Node.js 等必要依赖):curl -fsSL https://openclaw.ai/install.sh | bash
安装过程中,一些步骤可以跳过,后面再配置
第三步:初始化配置 (Onboarding)
安装完成后,启动配置向导并将其注册为后台守护进程:openclaw onboard --install-daemon
第四步:配置openclaw.json
cd /home/yourloginname/.openclaw
vim openclaw.json
这里贴出配置文件信息:
{
"wizard": {
"lastRunAt": "2026-03-26T02:07:01.081Z",
"lastRunVersion": "2026.3.24",
"lastRunCommand": "onboard",
"lastRunMode": "local"
},
"agents": {
"defaults": {
model: { primary: "bailian/qwen3.5-plus" }, # model配置原配置文件就有,修改成你用的大模型
models: { # models配置原配置文件就有,修改成你用的大模型
"bailian/qwen3.5-plus": { alias: "通义千问 Max Thinking 版" }
},
"workspace": "/home/xglee/.openclaw/workspace"
}
},
models: { # 这个models原配置文件没有,自己添加的,我用的阿里云百炼,注意替换自己的百炼apikey
mode: "merge",
providers: {
bailian: {
baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
apiKey: "sk-9681xxxxxxxxxxxxxxxxxx",
api: "openai-completions",
models: [
{
id: "qwen3.5-plus",
name: "通义千问 Max Thinking 版",
reasoning: false,
input: ["text"],
cost: { input: 0.0025, output: 0.01, cacheRead: 0, cacheWrite: 0 },
contextWindow: 262144,
maxTokens: 32768
}
]
}
}
},
"tools": {
"profile": "messaging"
},
"commands": {
"native": "auto",
"nativeSkills": "auto",
"restart": true,
"ownerDisplay": "raw"
},
"session": {
"dmScope": "per-channel-peer"
},
"gateway": {
"port": 18789,
"mode": "local",
"bind": "loopback",
"auth": {
"mode": "token",
"token": "37980ee74e1227bdc1a74501a105xxxxxxxxxx"
},
"tailscale": {
"mode": "off",
"resetOnExit": false
},
"nodes": {
"denyCommands": [
"camera.snap",
"camera.clip",
"screen.record",
"contacts.add",
"calendar.add",
"reminders.add",
"sms.send"
]
}
},
"meta": {
"lastTouchedVersion": "2026.3.24",
"lastTouchedAt": "2026-03-26T02:07:01.093Z"
}
}
可能遇到的问题:vim打开文件默认是replace模式,不方便编辑,这里调成insert模式,
解决方案:
切换到root账户,修改 vim 配置文件( /etc/vim/vimrc或者~/.vimrc),添加:
set termencoding=utf-8
set fileformats=unix
set encoding=prc
第五步:启动
由于OpenClaw运行在WSL2中,需要配置端口转发以便Windows访问。
创建启动脚本 start-openclaw.bat:
@echo off
echo Starting OpenClaw Gateway in WSL2...
wsl -d Ubuntu-22.04 -u root service openclaw start
timeout /t 3
start http://localhost:18789
或直接在WSL2中启动:
# 在WSL2 Ubuntu终端中
openclaw gateway run --port 18789
然后在Windows浏览器访问 http://localhost:18789
注意,不同版本openclaw可能表现不同,如果跳转地址是:http://127.0.0.1:18789/chat?session=agent%3Amain%3Amain
会有一个登录界面,好像报错,输入openclaw.json里面的token登录即可
系统优化与进阶建议
wsl内存
- 限制 WSL 内存占用:WSL2 默认资源占用较高。建议在 Windows 用户目录(
C:\Users\<你的用户名>\)下新建.wslconfig文件,填入以下内容限制资源:
[wsl2]
# 限制 WSL2 使用的内存(单位:GB)
memory=16GB
# 限制处理器核心数
processors=8
# 交换空间大小
swap=8GB
# 交换文件位置
swapFile=C:\\temp\\wsl-swap.vhdx
配置完成后,在 PowerShell 中执行:
wsl --shutdown
然后重新启动 Ubuntu。
ftp管理ubuntu
windows和linux交换可以使用ftp,
需要在Ubuntu安装开启ftp
先安装vsftpd
sudo apt install vsftpd
安装后找到配置文件
sudo vim /etc/vsftpd.conf
找到并设置下面选项
local_enable=YES
write_enable=YES
保存后重启
sudo /etc/init.d/vsftpd restart
这时在windows端可以通过ftp软件连接了,ip可以在Ubuntu通过ifconfig查到,127.0.0.1即可
我用的winscp,下载地址:
https://winscp.net/eng/index.php
可能会出现连接不上的情况,报错:VSFTPD 500 OOPS: priv_sock_get_cmd,
解决办法
修改系统的/etc/vsftpd.conf 文件,将下面的两行内容添加到文件末尾
seccomp_sandbox=NO
isolate_network=NO
其他解决办法
该现象还有可能是selinux(安全增强型 Linux)导致的,关闭selinux即可.
临时关闭
输入命令setenforce 0,重启系统后还会开启,如果提示该命令不存在可以执行sudo apt install selinux-utils命令安装该工具
永久关闭
输入命令sudo vi /etc/selinux/config,将SELINUX=enforcing改为SELINUX=disabled,然后按esc输入:wq保存退出
查看selinux状态
执行getenforce或/usr/sbin/sestatus -v命令查看状态
更多推荐




所有评论(0)