指南February 2, 2026

如何使用 OpenClaw 在 VPS 上运行 Claude Code:完整安装指南

在 VPS 上使用 OpenClaw 运行 Claude Code 的分步指南。连接 WhatsApp、Telegram、Discord 等。

如何在 VPS 上使用 OpenClaw 运行 Claude Code

OpenClaw 让您可以在任何 VPS 上运行 Claude Code 并连接到消息平台。以下是完整安装指南。

前置要求

  • Ubuntu 22.04+ 的 VPS
  • 最少 2GB RAM
  • Anthropic API 密钥
  • Node.js 18+

步骤 1:VPS 设置

bash

sudo apt update && sudo apt upgrade -y

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -

sudo apt install -y nodejs

npm install -g pm2



步骤 2:安装 OpenClaw

bash

git clone https://github.com/openclaw/openclaw.git

cd openclaw

npm install

cp .env.example .env



步骤 3:配置环境

编辑 `.env` 文件:


ANTHROPIC_API_KEY=your_key_here

CLAUDE_MODEL=claude-sonnet-4-5

MAX_TOKENS=4096



步骤 4:平台集成

WhatsApp

bash

npm install @openclaw/whatsapp-adapter



Telegram

bash

npm install @openclaw/telegram-adapter



Discord

bash

npm install @openclaw/discord-adapter



步骤 5:使用 PM2 运行

bash

pm2 start npm --name "openclaw" -- start

pm2 startup

pm2 save



安全最佳实践

1. 使用环境变量存储密钥

2. 启用防火墙(UFW)

3. 定期安全更新

4. 监控 API 使用量

成本考量

  • VPS:$5-20/月
  • Claude API:按使用量计费
  • 典型使用:总计 $10-50/月

总结

OpenClaw 提供了一种高效方式在多个平台上运行 Claude Code。按照本指南操作即可获得生产就绪的部署。

Ready to Experience Claude 5?

Try Now