OpenClaw 部署实战(二):Mac 安装全流程

Mac部署
macos小于13,先升级版本号,否则建议云部署
1.Qoder安装
安装 OpenClaw 的时候需要用 Qoder 跑终端命令。如果遇到报错,直接让Qoder帮你解决就行。
如果你已经装了 Qoder,可以跳过这步。
先去官网下载 Qoder:Qoder - The Agentic Coding Platform
遇到问题不用慌,选中终端里的错误信息,直接问Qoder,它会告诉你怎么解决。
下载好之后安装Qoder,拖拽安装
打开Qoder进行安装,选择skip
选择中文
注册/登录Qoder账号
配置中修改界面展示语言及AI回复语言
选择一个文件夹打开,到这一步安装就算结束了
2.OpenClaw安装
打开Qoder,点击右上角这里,会弹出输入框
输入以下命令:

sudo curl -fsSL https://openclaw.ai/install.sh | bash

注意看一下前面带没带sudo,要带,是打开权限
然后有可能会弹出password:
这个是让你输入电脑密码,电脑为了保护你的隐私,输入密码后不会显示,也就是说,按完密码,屏幕上看起来是没变化的,这是正常的,回车即可。
到这里需要等待一段时间,让他下载,慢是正常的,如果卡住就是没有开虚拟网卡模式
当出现终端出现OPENCLAW的时候,就安装完成了。
注意!如果这一步出现问题,那么就跳转这里解决:OpenClaw部署
3.Openclaw设置
方向键选Yes
回车后继续选择QuickStart
选择skip for now:
继续选All providers
继续回车
选Skip for now,继续回车:
选择No
这里需要先空格,然后回车
上下键选择第二个:
回车,安装完成后就会打开网页了,但是此时还不能发起会话:
4.API设置
将以下内容告诉给AI IDE,让它帮你配置API:
选择新建文件
命名为api-configure-skill.md
在里面复制以下内容并粘贴:

api key配置
# OpenClaw Model Configuration

Interactive guide for configuring OpenClaw models.

## Usage

Users will provide a JSON configuration file in the following format:

```json
{
  "models": {
    "mode": "merge",
    "providers": {
      "bailian": {
        "baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
        "apiKey": "<API_KEY>",
        "api": "openai-completions",
        "models": [
          {
            "id": "<MODEL_ID>",
            "name": "<MODEL_ID>",
            "reasoning": false,
            "input": ["text"],
            "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
            "contextWindow": 128000,
            "maxTokens": 8192
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": { "primary": "bailian/<MODEL_ID>" },
      "models": { "bailian/<MODEL_ID>": {} }
    }
  },
  "gateway": { "mode": "local" }
}

Step 1: Get Configuration

User provides the complete JSON configuration file. If not provided, ask for it.

Step 2: Write to Both Configuration Files

Write to both paths to ensure configuration consistency:

File macOS / Linux Windows
models.json ~/.openclaw/agents/main/agent/models.json %USERPROFILE%\.openclaw\agents\main\agent\models.json
openclaw.json ~/.openclaw/openclaw.json %USERPROFILE%\.openclaw\openclaw.json

File 1: models.json

Extract the models.providers section from user’s JSON:

{
  "providers": {
    "bailian": { ... }
  }
}

File 2: openclaw.json

Use the complete JSON configuration provided by user.

Step 3: Execute Configuration Commands

macOS / Linux

# Write models.json
cat > ~/.openclaw/agents/main/agent/models.json << 'EOF'
<extracted providers config>
EOF

# Write openclaw.json
cat > ~/.openclaw/openclaw.json << 'EOF'
<user's complete config>
EOF

Windows (PowerShell)

# Write models.json
$modelsJson = @'
<extracted providers config>
'@
$modelsJson | Set-Content "$env:USERPROFILE\.openclaw\agents\main\agent\models.json" -Encoding UTF8

# Write openclaw.json
$openclawJson = @'
<user's complete config>
'@
$openclawJson | Set-Content "$env:USERPROFILE\.openclaw\openclaw.json" -Encoding UTF8

Step 4: Auto-Execute Post-Configuration Tasks (MANDATORY)

IMPORTANT: After writing configuration files, you MUST automatically execute ALL of the following commands in sequence. Do NOT just display them - actually run them using the terminal.

4.1 Restart Gateway (Required)

Restart the Gateway to apply the new configuration:

macOS / Linux:

openclaw gateway --force --port 18789

Windows (PowerShell):

openclaw gateway --force --port 18789

4.2 Verify Configuration (Required)

Test the configuration by sending a message:

macOS / Linux:

openclaw agent --session-id main --message "hello"

Windows (PowerShell):

openclaw agent --session-id main --message "hello"

4.3 Start Dashboard (Required)

Ask the user if they want to open the Dashboard. If yes, execute:

macOS / Linux:

openclaw dashboard

Windows (PowerShell):

openclaw dashboard

Reminder: All commands in Step 4 MUST be executed automatically after configuration. Never skip these steps.


Troubleshooting

Error: HTTP 401 - Invalid access token or token expired

Cause: Incorrect API Key or wrong baseUrl in configuration.

Solution:

  1. Verify the API Key is correct
  2. For Alibaba Cloud Bailian, use the correct endpoint:
    https://dashscope.aliyuncs.com/compatible-mode/v1
    
    NOT https://coding.dashscope.aliyuncs.com/v1
  3. Ensure both models.json and openclaw.json have the same API Key

Error: Dashboard cannot connect / ERR_CONNECTION_REFUSED

Cause: Gateway service is not running.

Solution:

  1. Start the Gateway first:
    openclaw gateway --port 18789
    
  2. Then open Dashboard:
    openclaw dashboard
    

Error: Configuration changes not taking effect

Cause: Gateway needs to be restarted after configuration changes.

Solution:

openclaw gateway --force --port 18789

Error: Model not found / not available

Cause: Model ID does not exist in the provider’s supported models.

Solution:

  1. Check available models:
    openclaw models list
    
  2. Verify the model ID matches the provider’s official model name

Error: WebSocket disconnected / token_missing

Cause: Dashboard opened without authentication token.

Solution:

  1. Use the complete Dashboard URL with token:
    openclaw dashboard
    
  2. This will open the browser with the correct token in the URL

References


前往以下表格:API KEY
注意!表格中的API KEY是共享的,为了避免被平台限流、禁用,大家一定要选择未使用的,确认自己要使用这个之后,将下拉框换为已使用:
然后复制其中内容(不可用的话就换其他的试试,先别用deepseek的):
再新建一个文件:
命名为api-key.json
在里面粘贴刚刚从在线表格中复制的内容:
点击这里:
选择极致:
输入内容:

参考api-configure-skill.md帮我配置api-key.json中的内容


点击发送:
会帮你自动把api-key配置进去:
配置成功后,即可开始对话:

---

**相关文章:**
- [OpenClaw 本地部署教程(一):安装与 macOS/Linux 详解](/t/757)
- [OpenClaw 本地部署教程(二):Windows WSL2 + 渠道接入](/t/758)
- [OpenClaw 部署实战(一):Windows + Qoder 完整安装指南](/t/759)
- [OpenClaw 部署实战(三):云部署与钉钉飞书集成](/t/761)
2 个赞

Mac安装比Windows简单多了

1 个赞

brew安装很方便

1 个赞

权限弹窗记得全部允许

@sunhaoyu brew安装是Mac上最简单的方式 但要确保Homebrew本身是最新版 先brew update再安装OpenClaw

@liangtianqing 权限弹窗全部允许之前看清楚是什么权限 不要无脑点允许 特别是完全磁盘访问权限要谨慎