Deploying a Self-Hosted AI Assistant on Ubuntu 24.04: Full Integration Guide for Large Language Models
This guide provides step-by-step instructions for deploying a self-hosted AI assistant platform on Ubuntu 24.04 LTS, covering system requirements, core platform installation, LLM service integration, security configurations, and maintenance best practices.
System Requirements & Setup
Server Specifications
Recommended Ubuntu 24.04 LTS configuration:
- CPU: 4 cores (8+ preferred for production)
- Memory: 16GB RAM (32GB for high concurrency)
- Storage: 100GB+ SSD-based disk space
- Network: Static public IP or VPN solution
Security Recommendation: While root access is used in examples, create dedicated users for production:
sudo useradd -m aiuser && sudo passwd aiusersudo usermod -aG sudo aiuser
Node.js Environment
Install using nvm for version management:
# Install dependenciessudo apt update && sudo apt install -y curl git# Install nvmcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashsource ~/.bashrc# Install LTS Node.jsnvm install 22nvm alias default 22node -v # Should show v22.x.x
Core Platform Installation
Global Installation
npm install -g openclaw@latest --unsafe-perm=true --allow-root
Parameters Explained:
--unsafe-perm: Resolves permission issues--allow-root: Permits root installation (avoid in production)
Troubleshooting:
- For
ENOTEMPTYerrors:rm -rf /root/.npm-global/lib/node_modules/openclawnpm cache clean --force
- Network timeouts: Use registry mirrors:
npm config set registry https://registry.npmjs.org/
Verify Installation
openclaw --version # Should show version like 2026.3.2
LLM Service Integration
Obtain API Credentials
- Register with your preferred LLM provider
- Create dedicated project
- Generate API key (note the
sk-prefix) - Select nearest service region
Configuration Wizard
openclaw config
Interactive setup steps:
- Select “Add custom provider”
- Enter provider name (e.g.,
zhipu-glm) - Set API endpoint (example format):
https://api.example.com/v1/chat/completions
- Paste API key (mask sensitive characters)
- Test connection (optional)
Advanced Configuration (config.json):
{"providers": {"zhipu-glm": {"apiBase": "https://api.example.com/v1","apiKey": "sk-xxxxxxxxxxxxxxxx","maxTokens": 4096,"temperature": 0.7}}}
Secure Access Methods
SSH Tunneling
ssh -L 3000:localhost:3000 username@server_ip -N
Access via http://localhost:3000
Advantages:
- No exposed web ports
- End-to-end encryption
- Network-agnostic
Nginx Reverse Proxy (Production)
- Install Nginx:
sudo apt install -y nginx
- Configure SSL (Let’s Encrypt example):
sudo apt install -y certbot python3-certbot-nginxsudo certbot --nginx -d yourdomain.com
Proxy configuration:
server {listen 443 ssl;server_name yourdomain.com;location / {proxy_pass http://localhost:3000;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;}ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;}
Maintenance Best Practices
Log Management
Configure log rotation:
sudo mkdir /var/log/openclawsudo chown aiuser:aiuser /var/log/openclaw
Create /etc/logrotate.d/openclaw:
/var/log/openclaw/*.log {dailymissingokrotate 7compressdelaycompressnotifemptycreate 640 aiuser aiuser}
Performance Optimization
For high concurrency:
- Adjust Node.js memory:
export NODE_OPTIONS="--max-old-space-size=8192"
- Enable clustering (if supported):
openclaw start --workers 4
Backup Strategy
Regularly backup:
- Configuration:
~/.openclaw/ - Model caches (if applicable)
- External databases
Troubleshooting Guide
Common Errors
| Code | Cause | Solution |
|---|---|---|
| 500 | Model service error | Check provider status page |
| 403 | Invalid credentials | Regenerate API key |
| 429 | Rate limiting | Adjust concurrency or upgrade plan |
| ECONNREFUSED | Network issue | Verify firewall rules |
Diagnostic Commands
# Service statussystemctl status openclaw # If using systemd# Real-time logsjournalctl -u openclaw -f# Network testcurl -v https://api.example.com/health
Advanced Features
Multi-Model Routing
{"routing": {"default": "zhipu-glm","rules": [{"pattern": "^/tech/","provider": "tech-specialized-model"}]}}
Plugin Development
Example audit plugin:
// ~/.openclaw/plugins/audit.jsmodule.exports = {preProcess: (req) => {console.log(`Request from ${req.ip}`);},postProcess: (res) => {// Log response data}};
Upgrade & Rollback
Version Upgrade
# Check for updatesnpm outdated -g openclaw# Upgradenpm update -g openclaw
Rollback Procedure
# Backup current versioncp -r /usr/local/lib/node_modules/openclaw /usr/local/lib/node_modules/openclaw.bak# Install specific versionnpm install -g openclaw@2026.3.1
This deployment framework enables rapid establishment of self-hosted AI assistant platforms on Ubuntu 24.04 while maintaining flexibility for enterprise requirements. The modular architecture supports seamless integration with various LLM providers while implementing robust security and monitoring controls. For production environments, we recommend implementing comprehensive monitoring alerts and regular security audits.
