NewCode CLOUD — 20% off your first month on all cloud VPSClaim

Run a Private LLM on Your Server with Ollama and Open WebUI (CPU Guide)

Large language models no longer require a data centre. Ollama downloads and runs open models — Llama, Qwen, Gemma, Mistral, DeepSeek distillations and others — with one command, and exposes a simple HTTP API. On a server with plenty of RAM and CPU cores, small and medium models run fast enough for internal tools, document processing, chatbots with modest traffic and private experiments where data must not leave your infrastructure.

This guide installs Ollama on a CPU server, adds the Open WebUI chat interface, and explains what performance to expect.

What to expect without a GPU

LLM speed on CPU is limited mainly by memory bandwidth and core count. Rough guidance for quantised (Q4) models on a modern multi-core server:

Model size RAM needed (approx.) Typical CPU experience
1–4 B parameters 2–4 GB Fast; fine for classification, extraction, simple chat
7–9 B 6–8 GB Usable for chat and summarisation; a few to ~10+ tokens/s depending on CPU
13–14 B 10–12 GB Slower; good for batch jobs rather than live chat
30 B+ 20–40 GB+ Very slow on CPU; batch/offline only

Numbers vary widely with CPU generation, memory channels and context length — test with your own prompts. For high-volume or real-time use with large models, a GPU server or a hosted API is more cost-effective. CPU hosting shines for privacy, predictable cost and light-to-moderate workloads.

Choose a server with enough RAM for the model plus the operating system, and as many cores as practical. A dedicated server with 32–128 GB RAM can run several 7–14 B models comfortably.

Step 1: Install Ollama

curl -fsSL https://ollama.com/install.sh -o ollama-install.sh
less ollama-install.sh          # read what it does
sh ollama-install.sh

The script installs the binary, creates an ollama user and a systemd service. Check:

systemctl status ollama
ollama --version

Step 2: Run a model

ollama pull qwen2.5:7b
ollama run qwen2.5:7b

Type a prompt; /bye exits. Other good starting points: llama3.1:8b, gemma2:9b, mistral:7b, and small models such as qwen2.5:3b or llama3.2:3b for speed. Qwen models handle Chinese particularly well.

ollama list          # downloaded models
ollama ps            # loaded models and memory use
ollama rm MODEL      # delete

Models are stored in /usr/share/ollama/.ollama/models (for the service). Make sure that disk has room — a 7 B model is about 4–5 GB.

Step 3: Use the API

Ollama listens on 127.0.0.1:11434:

curl http://127.0.0.1:11434/api/generate -d '{
  "model": "qwen2.5:7b",
  "prompt": "Summarise in one sentence: Hong Kong servers offer low latency to mainland China.",
  "stream": false
}'

It also offers an OpenAI-compatible endpoint at /v1/chat/completions, so many tools and SDKs work by changing the base URL to http://127.0.0.1:11434/v1.

Step 4: Keep the API private

By default Ollama only listens on localhost, which is correct. The API has no authentication — never expose port 11434 to the internet. If other servers need it:

sudo systemctl edit ollama
[Service]
Environment="OLLAMA_HOST=10.10.0.2:11434"
sudo systemctl daemon-reload && sudo systemctl restart ollama
  • Or put Nginx in front with authentication (API key header or basic auth) and HTTPS.

Step 5: Tune for CPU

Useful environment variables (add them the same way with systemctl edit ollama):

Variable Purpose
OLLAMA_NUM_PARALLEL Concurrent requests per model (each needs extra memory for context)
OLLAMA_MAX_LOADED_MODELS How many models stay in RAM at once
OLLAMA_KEEP_ALIVE How long a model stays loaded after use (e.g. 30m, -1 = forever)
OLLAMA_CONTEXT_LENGTH Default context window; larger uses more RAM and is slower

Keeping a model loaded (OLLAMA_KEEP_ALIVE) avoids a load delay of several seconds on each first request. Watch memory with ollama ps and free -h; if the server swaps, performance collapses — use a smaller model or quantisation.

Step 6: Open WebUI (chat interface)

Open WebUI provides a ChatGPT-like interface with users, history, document upload (RAG) and model management. With Docker (install Docker):

docker run -d --name open-webui --restart unless-stopped \
  -p 127.0.0.1:3000:8080 \
  --add-host=host.docker.internal:host-gateway \
  -e OLLAMA_BASE_URL=http://host.docker.internal:11434 \
  -v open-webui:/app/backend/data \
  ghcr.io/open-webui/open-webui:main

A container cannot reach the host’s 127.0.0.1, so Ollama must also listen on the Docker bridge address — which is not reachable from the internet:

sudo systemctl edit ollama
[Service]
Environment="OLLAMA_HOST=172.17.0.1:11434"
sudo systemctl daemon-reload && sudo systemctl restart ollama
sudo ufw allow in on docker0 to any port 11434 proto tcp    # if UFW is active
export OLLAMA_HOST=172.17.0.1:11434                         # for the ollama CLI in your shell

Check the bridge address with ip -br a show docker0 (it is usually 172.17.0.1). Never use 0.0.0.0 unless a firewall blocks port 11434 from outside.

Publish Open WebUI through a reverse proxy with HTTPS (see Nginx reverse proxy — the proxy configuration is the same, including WebSocket headers). The first account created becomes admin; create it immediately and disable open sign-ups in the admin settings.

Use cases that work well on CPU

  • Private document Q&A over internal manuals with Open WebUI’s document feature.
  • Classification and extraction: tagging support tickets, extracting fields from emails or invoices with a small model.
  • Translation and summarisation in batch jobs overnight.
  • Automation: call the local model from n8n workflows so sensitive data never leaves your server.
  • Development and testing of AI features before switching to a hosted API.

Hosting location

Ollama downloads models from its registry; after that it runs entirely offline. Where you host depends on your users and data rules. If your application also calls hosted APIs (OpenAI, Claude, Gemini), note that those providers do not serve Hong Kong; servers in Japan, Singapore or the US can call them directly — see AI hosting.

Troubleshooting

Problem Fix
Very slow responses Smaller model or lower quantisation; check that the server is not swapping
“model requires more system memory” Not enough free RAM — free memory or use a smaller model
Open WebUI shows no models Wrong OLLAMA_BASE_URL, or Ollama only listening on 127.0.0.1
First answer takes long, later ones fast Model loading — increase OLLAMA_KEEP_ALIVE