macOS 安装 OpenClaw 指南
# macOS 安装 OpenClaw 指南
在 Mac 上安装 OpenClaw AI 助手平台
环境要求
- macOS 12 (Monterey) 或更高版本
- 4GB+ RAM
- Homebrew 已安装
第一步:安装 Homebrew
bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"第二步:安装依赖
bash
# 安装 Node.js 20
brew install node@20
# 安装 PostgreSQL
brew install postgresql@14
brew services start postgresql
# 创建数据库
createuser -s openclaw
createdb openclaw
psql -c "ALTER USER openclaw WITH PASSWORD 'password123';" postgres第三步:安装 OpenClaw
bash
# 克隆项目
cd ~/Developer
git clone https://github.com/openclaw/openclaw.git
cd openclaw
# 安装依赖
npm install
# 配置环境变量
cp .env.example .env
nano .env配置内容:
env
DATABASE_URL=postgresql://openclaw:password123@localhost:5432/openclaw
JWT_SECRET=your-secret-key
AI_PROVIDER=openai
OPENAI_API_KEY=sk-your-key第四步:初始化并启动
bash
# 生成 Prisma 客户端
npx prisma generate
# 同步数据库
npx prisma db push
# 启动开发服务器
npm run dev第五步:访问
浏览器打开 http://localhost:3000
使用 LaunchAgent 开机自启 (可选)
创建 ~/Library/LaunchAgents/com.openclaw.plist:
xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.openclaw</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/node</string>
<string>/Users/yourusername/Developer/openclaw/index.js</string>
</array>
<key>WorkingDirectory</key>
<string>/Users/yourusername/Developer/openclaw</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>加载:
bash
launchctl load ~/Library/LaunchAgents/com.openclaw.plist常见问题
PostgreSQL 无法启动
bash
brew services restart postgresql@14端口被占用
bash
lsof -i :3000
# 或修改 .env 中的 PORT---
相关教程:
- [Ubuntu 安装](/post/install-openclaw-ubuntu)
- [Docker 安装](/post/install-openclaw-docker)
相关文章
Ubuntu/Debian 系统安装 OpenClaw 完整指南
详细步骤指南:在 Ubuntu 和 Debian 系统上安装 OpenClaw AI 助手平台,包含开发环境和生产环境配置。
2026-03-20CentOS/RHEL 系统安装 OpenClaw 指南
# CentOS/RHEL 系统安装 OpenClaw 指南 > 本教程详细介绍如何在 CentOS Stream 9 或 RHEL 9 上安装 OpenClaw ## 环境要求 - CentO
2026-03-20Windows WSL2 安装 OpenClaw 教程
在 Windows 11/10 上通过 WSL2 Ubuntu 安装 OpenClaw 的详细教程,适合开发环境。
2026-03-20