Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Self-Host Your Own AI Assistant on a VPS

· 5 min read · Smart Home

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide walks you through setting up your own private AI assistant on a virtual private server (VPS). You'll end up with a web-based chat interface that runs open-source language models, giving you full control over your data and usage. No prior server experience is required, but basic comfort with a terminal helps.

What You'll Need

  • A VPS with at least 8GB RAM (16GB recommended for larger models). Linux (Ubuntu 22.04 or 24.04) is assumed.
  • SSH access to the server (root or a user with sudo privileges).
  • A domain name (optional but recommended for HTTPS).
  • Basic familiarity with the command line.

Step-by-Step

  1. Connect to your VPS via SSH: ssh user@your_server_ip. Update the system: sudo apt update && sudo apt upgrade -y.
  2. Install Docker and Docker Compose (the easiest way to run the AI stack). Follow the official Docker installation docs for Ubuntu, then enable the service: sudo systemctl enable --now docker. Add your user to the docker group: sudo usermod -aG docker $USER (log out and back in).
  3. Install NVIDIA drivers and CUDA if your VPS has a GPU (many do not). For CPU-only setups, skip this step. For GPU, install the proprietary driver and CUDA toolkit from NVIDIA's repository, then verify with nvidia-smi.
  4. Set up a project directory: mkdir ~/ai-assistant && cd ~/ai-assistant. Create a docker-compose.yml file.
  5. Add the Open WebUI service to your compose file. This provides the chat interface. Use the official image: ghcr.io/open-webui/open-webui:main. Map port 3000 to the host, and mount a volume for persistent data.
  6. Add the Ollama service for running models. Use the official image: ollama/ollama. Mount a volume for models, and expose port 11434. In the Open WebUI service, set the environment variable OLLAMA_BASE_URL=http://ollama:11434 so they can talk to each other.
  7. Start the services: docker-compose up -d. Wait a minute, then check logs: docker-compose logs -f. You should see both containers running.
  8. Open your browser to http://your_server_ip:3000. Create an admin account (the first account becomes admin). You'll be greeted by the chat interface.
  9. Download a model inside the interface: go to Settings → Models, and pull a model like llama3.2:3b (small, works on CPU) or mistral:7b (better, needs more RAM). The download may take a few minutes.
  10. Start chatting! Select the model from the dropdown and send a message. The assistant will respond.
  11. Set up a reverse proxy for HTTPS (optional but recommended). Install Nginx, configure a server block for your domain, proxy to localhost:3000, and use Certbot to get a free SSL certificate.
  12. Enable firewall: allow SSH (port 22) and HTTP/HTTPS (80/443), and block direct access to port 3000 from outside (only allow through the proxy). Use ufw or your provider's firewall.

Common Mistakes

  • Not enough RAM: Running a 7B model on a 4GB VPS will cause crashes or extreme slowness. Stick to 3B models or smaller on low-RAM servers.
  • Forgetting to set OLLAMA_BASE_URL: If the interface can't connect to Ollama, you'll get a connection error. Double-check the environment variable.
  • Exposing the service without a firewall: Leaving port 3000 open to the internet invites abuse. Always restrict access.
  • Using the wrong Docker volume syntax: Ensure volumes are correctly mounted (e.g., ./data:/root/.ollama). Otherwise, models disappear after a restart.
  • Ignoring logs: When something fails, check docker-compose logs first. It usually tells you exactly what's wrong.

Tips

  • For CPU-only servers, choose models with 3B parameters or less (e.g., llama3.2:3b, phi3:mini). They're still capable and run at usable speeds.
  • Use a GPU if possible; even a small GPU makes a huge difference in speed.
  • Back up your data volumes regularly (the ./data folder).
  • Update the images periodically: docker-compose pull && docker-compose up -d.
  • Set up a swap file if your VPS has limited RAM, but know it's not a substitute for real memory.

Troubleshooting

  • Interface won't load: Check if the container is running (docker ps). If not, look at logs. Common cause: port 3000 already in use or Docker daemon not running.
  • Model download fails: Often a network issue. Try pulling the model manually from the server: docker exec -it ollama ollama pull llama3.2:3b. If that fails, check your internet connection and DNS.
  • Slow responses: You're likely out of RAM or CPU. Reduce the model size or upgrade your VPS. Also, ensure no other heavy processes are running.
  • Connection refused between services: Verify the services are on the same Docker network (default compose network). Check the OLLAMA_BASE_URL spelling.
  • After reboot, services don't start: Set restart: unless-stopped in your compose file for both services.

Frequently Asked Questions

Can I run this on a free or very cheap VPS?

You can, but the experience will be poor. A 2GB VPS can run a 1B model, but expect slow responses. For a decent experience, get at least 8GB RAM.

Which models work best on CPU?

Small quantized models like llama3.2:3b, phi3:mini, or qwen2.5:1.5b are good choices. They balance speed and capability.

Is my data private?

Yes, everything runs on your server. No data leaves your VPS unless you configure external integrations. That's the main advantage of self-hosting.

Can I use multiple models at once?

Yes, you can pull multiple models and switch between them in the interface. They share the same RAM, so be mindful of total size.

How do I update the software?

Pull new images and recreate containers: docker-compose pull && docker-compose up -d. Your data and models persist.

Can I expose this to the internet?

Yes, but use a reverse proxy with HTTPS and strong authentication. The default setup has no encryption, so never expose it directly.