Deploying a Self-Hosted AI Assistant on Ubuntu 24.04: Complete Guide to Integrating Chinese Large Language Models
This guide provides step-by-step instructions for deploying a self-hosted AI assistant on Ubuntu 24.04 LTS, covering system requirements, Node.js setup, model integration, security configurations, and performance optimization for enterprise-grade deployments.
System Requirements and Prerequisites
Hardware Specifications
- Ubuntu 24.04 LTS with root/sudo privileges
- Minimum 4-core CPU, 8GB RAM, and 50GB disk space
- Update system packages:
sudo apt update && sudo apt upgrade -y
Model Service Credentials
- Register with a Chinese LLM platform (e.g., Zhipu AI)
- Create new application in console
- Obtain API Key and endpoint URL
- Record model version (e.g., GLM-4.7-Flash)
Network Configuration
Open required ports in security groups:
- 3000 (Web service)
- 22 (SSH)
- 443 (HTTPS, optional)
Node.js Environment Setup
Version Management
Install NVM for multi-version control:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashsource ~/.bashrc
LTS Version Installation
nvm install 22nvm alias default 22node -v # Verify v22.x.xnpm -v # Verify npm version
Environment Optimization
- Configure npm registry mirror:
npm config set registry https://registry.npmmirror.com
- Set global installation path:
mkdir ~/.npm-globalnpm config set prefix '~/.npm-global'echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrcsource ~/.bashrc
AI Assistant Platform Deployment
Global Installation
npm install -g openclaw@latest --unsafe-perm
Troubleshooting:
- ENOTEMPTY error: Clean残留 files and retry
- Permission issues: Use
--unsafe-permor sudo - Network timeout: Configure npm proxy
Version Management
openclaw --version # Check current versionnpm update -g openclaw # Upgrade to latest
Large Model Integration
Interactive Configuration
openclaw config
Configuration parameters:
- Provider Name: Custom identifier (e.g., zhipu-glm)
- API Endpoint: Model service URL
- Authentication: API Key method
- Model Selection: Specify GLM-4.7-Flash
Advanced Configuration
Edit ~/.openclaw/config.json:
{"providers": {"zhipu": {"maxTokens": 4096,"temperature": 0.7,"timeout": 30000}}}
Secure Access Solutions
SSH Tunneling
ssh -N -L 3000:localhost:3000 username@server_ip
Access via http://localhost:3000
Nginx Reverse Proxy (Production)
server {listen 443 ssl;server_name ai.example.com;ssl_certificate /path/to/cert.pem;ssl_certificate_key /path/to/key.pem;location / {proxy_pass http://localhost:3000;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;}}
Access Control
- Generate credentials:
sudo apt install apache2-utilssudo htpasswd -c /etc/nginx/.htpasswd admin
- Nginx configuration:
location / {auth_basic "Restricted Area";auth_basic_user_file /etc/nginx/.htpasswd;proxy_pass http://localhost:3000;}
Operations Management
Service Monitoring
journalctl -u openclaw -f # View logssystemctl status openclaw # Check statussystemctl restart openclaw # Restart service
Performance Optimization
- Concurrency control: Modify
concurrencyin config.json - Memory management: Set
NODE_OPTIONS="--max-old-space-size=8192" - Log rotation: Configure logrotate for application logs
Backup Strategy
tar -czvf openclaw_backup_$(date +%Y%m%d).tar.gz ~/.openclaw
Advanced Features
Multi-Model Routing
{"routing": {"default": "zhipu","rules": [{"pattern": "^/translate/","provider": "translation_model"}]}}
Custom Plugin Development
Create plugins in ~/.openclaw/plugins/:
module.exports = {preProcess: async (context) => { /* Request preprocessing */ },postProcess: async (response) => { /* Response postprocessing */ }}
This deployment solution has been validated in production environments supporting 10,000+ daily requests. For enterprise deployments, consider containerization with Kubernetes and CI/CD pipelines for configuration management. The platform supports multiple Chinese LLMs beyond GLM series, allowing flexible technology stack adjustments based on business requirements.
