Self-Hosted AI Assistant Deployment on Ubuntu 24.04 with Chinese LLM Integration: Complete Guide

    This guide provides a step-by-step implementation for deploying a self-hosted AI assistant platform on Ubuntu 24.04, supporting integration with Chinese large language models while maintaining data sovereignty and security. The solution emphasizes multi-model compatibility, secure access, and enterprise-grade deployment patterns.

    1. Technical Architecture & Core Value

    The self-hosted AI assistant platform addresses growing enterprise needs for data privacy and model customization through three key capabilities:

    • Multi-Model Support: Native compatibility with GLM, Llama, and other mainstream architectures
    • Omnichannel Access: Web console, CLI tools, and IM platform integrations
    • Security Isolation: SSH tunneling for private network access without public exposure

    Compared to SaaS alternatives, this approach offers significant advantages in data control, latency optimization, and cost efficiency—particularly critical for financial and healthcare sectors requiring strict compliance.

    2. Environment Setup & Security

    2.1 System Requirements

    • Server Specs: Ubuntu 24.04 LTS (4vCPU/8GB RAM minimum recommended)
    • Network: Open ports 22 (SSH) and 3000 (default web)
    • Security Hardening:
      • SSH key authentication only
      • UFW firewall configured for minimal exposure
      • Regular patching (sudo apt update && sudo apt upgrade)

    2.2 Node.js Management

    Recommended installation via nvm for version control:

    1. # Install nvm
    2. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    3. source ~/.bashrc
    4. # Install LTS version
    5. nvm install --lts
    6. nvm alias default node
    7. # Verify installation
    8. node -v # Should show v18.x+
    9. npm -v # Should show 9.x+

    3. OpenClaw Deployment

    3.1 Global Installation

    1. # Install with permission handling
    2. sudo npm install -g openclaw@latest --unsafe-perm
    3. # Troubleshooting installation failures
    4. if [ $? -ne 0 ]; then
    5. rm -rf $(npm root -g)/openclaw
    6. npm cache clean --force
    7. mkdir -p ~/.openclaw
    8. npm install -g openclaw@latest --prefix ~/.openclaw
    9. fi

    3.2 Configuration Optimization

    Edit ~/.openclaw/config.json:

    1. {
    2. "port": 3000,
    3. "ssl": {
    4. "enabled": false,
    5. "cert": "/path/to/cert.pem",
    6. "key": "/path/to/key.pem"
    7. },
    8. "rateLimit": {
    9. "max": 100,
    10. "windowMs": 60000
    11. }
    12. }

    4. Chinese LLM Integration

    4.1 API Service Registration

    1. Create application in provider console
    2. Obtain API Key and note:
      • Authentication: API Key
      • Endpoint: https://api.example.com/v1
      • Model: GLM-4.7-Flash

    4.2 Provider Configuration

    Interactive setup:

    1. openclaw config

    Follow prompts to:

    1. Select “Add custom provider”
    2. Name provider (e.g., “zhipu-glm”)
    3. Configure endpoint:
      1. Base URL: https://api.example.com/v1
      2. Authorization: Bearer YOUR_API_KEY
    4. Test connectivity

    4.3 Model Tuning

    Add to models configuration:

    1. {
    2. "name": "glm-4.7-flash",
    3. "provider": "zhipu-glm",
    4. "maxTokens": 2048,
    5. "temperature": 0.7,
    6. "topP": 0.9
    7. }

    5. Secure Access Patterns

    5.1 SSH Tunneling

    Local access without public exposure:

    1. ssh -N -L 3000:localhost:3000 username@server_ip

    Access via http://localhost:3000

    5.2 Nginx Production Proxy

    1. server {
    2. listen 443 ssl;
    3. server_name ai.example.com;
    4. ssl_certificate /path/to/fullchain.pem;
    5. ssl_certificate_key /path/to/privkey.pem;
    6. location / {
    7. proxy_pass http://localhost:3000;
    8. proxy_set_header Host $host;
    9. proxy_set_header X-Real-IP $remote_addr;
    10. }
    11. }

    6. Operations Framework

    6.1 Log Management

    Configure logrotate:

    1. /var/log/openclaw/*.log {
    2. daily
    3. missingok
    4. rotate 7
    5. compress
    6. delaycompress
    7. notifempty
    8. create 640 root adm
    9. sharedscripts
    10. postrotate
    11. systemctl reload openclaw
    12. endscript
    13. }

    6.2 Performance Monitoring

    Recommended Prometheus+Grafana stack:

    1. Expose /metrics endpoint
    2. Configure Node Exporter
    3. Set alerts for >500ms response times

    7. Troubleshooting Guide

    7.1 Port Conflicts

    1. # Identify conflicting process
    2. sudo lsof -i :3000
    3. # Terminate process
    4. sudo kill -9 <PID>

    7.2 Model Timeout

    Adjust config.json:

    1. {
    2. "providers": {
    3. "zhipu-glm": {
    4. "timeout": 60000 # 60 seconds
    5. }
    6. }
    7. }

    7.3 CORS Resolution

    Nginx configuration:

    1. add_header 'Access-Control-Allow-Origin' '*';
    2. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    3. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';

    8. Scalability Options

    1. Model Routing: Custom middleware for intelligent dispatch
    2. Session Persistence: Redis integration for context management
    3. Audit Logging: Comprehensive API call tracking
    4. Auto-Scaling: Kubernetes-based container orchestration

    The modular design enables immediate deployment while allowing selective feature adoption. Regularly monitor provider API updates for compatibility. For high-throughput scenarios, implement horizontal scaling with load balancers distributing traffic across multiple OpenClaw instances.