Deploying OpenClaw with LLM Integration on Ubuntu 24.04: A Complete Guide
This guide provides step-by-step instructions for deploying OpenClaw on Ubuntu 24.04 LTS and integrating it with large language model (LLM) services, covering environment setup, framework installation, service configuration, and production deployment best practices.
Prerequisites and Environment Setup
System Requirements
- Recommended OS: Ubuntu 24.04 LTS (LTS recommended for stability)
- Hardware: Minimum 4-core CPU with 8GB RAM (2-core/4GB for testing)
- User Access: Root privileges for setup (create dedicated user with sudo access for production)
Required Toolchain
# Node.js 22 LTS (recommended via nvm)curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashsource ~/.bashrcnvm install 22nvm alias default 22# Verify installationsnode -v # Should show v22.x.xnpm -v # Should show 9.x.x+# Additional toolssudo apt install git curl wget -y
LLM Service Credentials
- Obtain API access key from your cloud provider’s LLM service
- Store credentials in environment variables (e.g.,
OPENCLAW_MODEL_KEY) - Avoid hardcoding credentials in configuration files
OpenClaw Framework Installation
Install Node.js Modules
# Global installation with permission handlingnpm install -g openclaw@latest --unsafe-perm# Verify installationopenclaw --version # Should show 2026.x.x+
Troubleshooting Installation Issues
- ENOTEMPTY Errors: Clean previous installations with:
rm -rf $(npm root -g)/openclawnpm cache clean --force
- Permission Problems: Configure alternative global install path:
npm config set prefix '~/.npm-global'
LLM Service Configuration
Interactive Setup Wizard
openclaw config
Configuration Parameters
Provider Setup:
- Select “Add custom provider”
- Enter provider name (e.g.,
zhipu-provider)
API Configuration:
- Endpoint URL:
https://api.example.com/v4(replace with actual endpoint) - Authentication: API Key mode
- Key Management: Use environment variable injection
- Endpoint URL:
Advanced Settings (optional):
- Timeout: Increase from default 30s to 60s for unstable networks
- Retry Policy: Configure 3 retry attempts
- Concurrency: Set max concurrent requests based on server capacity
Configuration File Location:
~/.openclaw/config.json
Web Service Deployment
Service Startup
openclaw start --port 3000 --host 0.0.0.0
Secure Local Access (SSH Tunneling)
# Forward server port 3000 to local port 8080ssh -L 8080:localhost:3000 username@server_ip -N
- Access via browser:
http://localhost:8080
Production Security Recommendations
- Configure Nginx reverse proxy
- Enable HTTPS with Let’s Encrypt certificates
- Restrict access via firewall rules (e.g.,
ufwor cloud provider security groups)
Operations and Maintenance
Log Management
- Service logs:
/var/log/openclaw/service.log - Access logs:
/var/log/openclaw/access.log
Performance Monitoring
# Monitor resource usagetop -p $(pgrep -f openclaw)
Common Issues Resolution
- Model API failures: Verify key validity and network connectivity
- Unresponsive service: Check for OOM errors in logs
- Port conflicts: Modify startup port or terminate conflicting processes
Advanced Features
Multi-Model Support
Add multiple provider entries in config.json and implement model routing through API endpoints.
Custom Routing Configuration
{"/api/v1/chat": {"provider": "zhipu-provider","model": "glm-4.7-flash"}}
Rate Limiting
Implement QPS restrictions through middleware to prevent service abuse.
Production Deployment Best Practices
Containerization
FROM node:22-alpineWORKDIR /appCOPY . .RUN npm install --productionCMD ["openclaw", "start"]
High Availability Architecture
- Deploy multiple instances using Kubernetes
- Configure health checks and auto-restart policies
- Implement load balancing for request distribution
Backup Strategy
- Regularly backup configuration files and model data
- Store important logs in object storage services
This guide provides comprehensive coverage from initial environment setup to production deployment. Always validate configurations in testing environments before production migration, adjusting parameters according to specific business requirements. Refer to the official documentation for the latest framework updates and compatibility information.
