{"slug": "how-to-install-ollama-and-open-webui-on-a-linux-vps", "title": "How to install Ollama and Open WebUI on a Linux VPS", "summary": "A developer published a step-by-step guide for deploying Ollama 0.40.18 and Open WebUI v0.13.4 on an Ubuntu 24.04 VPS using Docker Compose and Caddy for automatic HTTPS. The setup keeps Ollama's unauthenticated port 11434 on a private Docker network, requires a WEBUI_SECRET_KEY, and disables public signups after the first admin account is created. The guide also maps 4-bit quantized model sizes to VPS memory tiers, recommending 12 GB of RAM for 7B-8B models to avoid OOM kills.", "body_md": "Running **Ollama** with **Open WebUI** on your own Linux VPS gives you a private AI chat interface and a local model API with flat monthly costs and zero third-party data sharing. This guide deploys **Ollama `0.40.18`** and **Open WebUI `v0.13.4`** on an Ubuntu 24.04 VPS using Docker Compose and **Caddy** for automatic HTTPS — keeping port `11434` isolated on the private Docker network and locking public signups right after creating your admin account.\n\nEvery image tag, environment variable and healthcheck below matches the upstream `v0.40.18` Ollama release (`envconfig/config.go` and `Dockerfile`) and `v0.13.4` Open WebUI release (`docker-compose.yaml`, `backend/open_webui/env.py`, `config.py` and `Dockerfile`).\n\nBefore deploying, set realistic expectations: on a standard Linux VPS (vCPUs and RAM, no dedicated GPU), Ollama runs inference on CPU using system memory bandwidth.\n\nThat works well for:\n\nA CPU-only VPS is not built for dozens of concurrent chat users or 32B/70B models. The table below summarizes practical 4-bit quantized (`Q4_K_M`, Ollama's default) model sizes by VPS memory:\n\n| VPS tier (CPU) | Comfortable models ( `Q4` ) | Recommended workload | \n|---|---|---|\n| 4 GB RAM · 2 vCPU | 1B to 3B models ( `llama3.2:3b` ) | Quick tests, embeddings ( `nomic-embed-text` ) and light triage | \n| 8 GB RAM · 4 vCPU | 3B to 4B models ( `qwen3:4b` ,`gemma3:4b` ) | Daily single-user chat in Open WebUI with safe memory headroom | \n| 12 GB RAM · 6 vCPU | 7B to 8B models ( `qwen2.5:7b` ,`llama3.1:8b` ) | Production Open WebUI, RAG and n8n workflows without OOM kills | \n| 24 GB RAM · 8 vCPU | 14B models or 8B with larger context windows | Small team usage, longer context and other stacks on the host | \n\n**Memory rule of thumb.** A 4-bit 8B model needs roughly 5 GB to 6 GB of RAM just for weights, plus KV context cache, the Open WebUI backend (~600 MB to 1 GB) and the OS. On an 8 GB VPS, an 8B model runs right on the edge; **12 GB of RAM** leaves genuine headroom so the Linux OOM killer does not terminate Ollama mid-generation.\n\nThe most common mistake when self-hosting Ollama on a VPS is publishing port `11434` on `0.0.0.0`. Ollama has **no built-in authentication**: anyone scanning your IP can pull arbitrary models, fill your disk and peg your CPU at 100%.\n\nIn this setup, only **Caddy** binds ports `80` and `443` on the host. **Open WebUI** (`8080`) and **Ollama** (` 11434`) communicate exclusively over the private Docker Compose network:\n\nFour details prevent the usual first-day pitfalls:\n\n`WEBUI_SECRET_KEY` is required in Open WebUI `v0.13.4`:` docker-compose.yaml` leaves it blank, but `env.py` explicitly aborts startup when `WEBUI_AUTH=True` and `ollama list`:` ollama/ollama:0.40.18` Ubuntu 24.04 image does not bundle `curl` or `wget`. Running `11434` is ready.`OLLAMA_MAX_LOADED_MODELS=1` and `OLLAMA_NUM_PARALLEL=1`:` ENABLE_SIGNUP=true` stays on only while you create the first account (automatically promoted to Admin), then switches to `false`.` v2.20+`), ideally `ufw` allowing only `22/tcp`, `80/tcp` and `443` (TCP/UDP).`A` record pointing to the VPS IPv4 (`ia.example.com` in the examples below).\nIf Docker and `ufw` are not configured yet, start with the server setup in [How to install n8n with Docker on a VPS](https://nuvits.net/en/blog/install-n8n-docker-vps).\n\n`.env`\nCreate the stack directory and generate a strong random `WEBUI_SECRET_KEY`:\n\n```\nmkdir -p ~/ollama-webui && cd ~/ollama-webui\nopenssl rand -hex 32\n```\n\nCreate `.env` with your domain, email and generated secret key:\n\n``` ini .env\n\nOLLAMA_VERSION=0.40.18\n\nOPEN_WEBUI_VERSION=v0.13.4\n\nCADDY_VERSION=2.11\n\nWEBUI_DOMAIN=ia.example.com\n\nACME_EMAIL=[you@example.com](mailto:you@example.com)\n\nWEBUI_URL=[https://ia.example.com](https://ia.example.com)\n\nWEBUI_SECRET_KEY=paste-your-64-char-hex-key-here\n\nENABLE_SIGNUP=true\n\nDEFAULT_USER_ROLE=pending\n\nOLLAMA_KEEP_ALIVE=5m\n\nOLLAMA_MAX_LOADED_MODELS=1\n\nOLLAMA_NUM_PARALLEL=1\n\nOLLAMA_CONTEXT_LENGTH=4096\n\n```\nLock down file permissions on `.env`:\n\n``` bash\nchmod 600 .env\n```\n\nWhat each Ollama guard in `.env` controls:\n\n`OLLAMA_KEEP_ALIVE=5m`:` OLLAMA_CONTEXT_LENGTH=4096`:` 8192` on 12 GB or 24 GB tiers if needed).`Caddyfile`\nCaddy provisions and renews the TLS certificate automatically and proxies both streamed chat responses and WebSockets to Open WebUI:\n\n``` caddy Caddyfile\n\n{\n\n    email {$ACME_EMAIL}\n\n}\n\n{$WEBUI_DOMAIN} {\n\n    encode zstd gzip\n\n    reverse_proxy open-webui:8080\n\n}\n\n```\n## Create `docker-compose.yml`\n\nThis Compose file pins tested tags, keeps `ollama` and `open-webui` off the host network interface and waits for Ollama to become healthy before starting the UI:\n\n``` yaml docker-compose.yml\nservices:\n  caddy:\n    image: caddy:${CADDY_VERSION}\n    restart: unless-stopped\n    ports:\n      - \"80:80\"\n      - \"443:443\"\n      - \"443:443/udp\"\n    environment:\n      - WEBUI_DOMAIN=${WEBUI_DOMAIN}\n      - ACME_EMAIL=${ACME_EMAIL}\n    volumes:\n      - ./Caddyfile:/etc/caddy/Caddyfile:ro\n      - caddy_data:/data\n      - caddy_config:/config\n    depends_on:\n      open-webui:\n        condition: service_healthy\n\n  ollama:\n    image: ollama/ollama:${OLLAMA_VERSION}\n    restart: unless-stopped\n    environment:\n      - OLLAMA_KEEP_ALIVE=${OLLAMA_KEEP_ALIVE}\n      - OLLAMA_MAX_LOADED_MODELS=${OLLAMA_MAX_LOADED_MODELS}\n      - OLLAMA_NUM_PARALLEL=${OLLAMA_NUM_PARALLEL}\n      - OLLAMA_CONTEXT_LENGTH=${OLLAMA_CONTEXT_LENGTH}\n    volumes:\n      - ollama_data:/root/.ollama\n    healthcheck:\n      test: [\"CMD\", \"ollama\", \"list\"]\n      interval: 15s\n      timeout: 5s\n      retries: 10\n      start_period: 15s\n\n  open-webui:\n    image: ghcr.io/open-webui/open-webui:${OPEN_WEBUI_VERSION}\n    restart: unless-stopped\n    environment:\n      - OLLAMA_BASE_URL=http://ollama:11434\n      - WEBUI_SECRET_KEY=${WEBUI_SECRET_KEY}\n      - WEBUI_URL=${WEBUI_URL}\n      - ENABLE_SIGNUP=${ENABLE_SIGNUP}\n      - DEFAULT_USER_ROLE=${DEFAULT_USER_ROLE}\n    volumes:\n      - open_webui_data:/app/backend/data\n    depends_on:\n      ollama:\n        condition: service_healthy\n\nvolumes:\n  caddy_data:\n  caddy_config:\n  ollama_data:\n  open_webui_data:\n```\n\n**No host `ports:` on Ollama or Open WebUI.** The `ghcr.io/open-webui/open-webui:v0.13.4` image already ships a built-in `HEALTHCHECK` against `http://localhost:8080/health`, so Caddy waits until the backend is ready. Never add `\"11434:11434\"` to `ollama`, because Docker bypasses `ufw` — see [Docker port still open with ufw](https://nuvits.net/en/blog/docker-port-still-open-with-ufw).\n\nValidate the Compose configuration and bring the stack up:\n\n```\ncd ~/ollama-webui\nsudo docker compose config --quiet\nsudo docker compose up -d\nsudo docker compose ps\n```\n\nThe first Open WebUI startup takes 1 to 2 minutes while it initializes its SQLite database and assets inside `/app/backend/data`. Wait until both `ollama` and `open-webui` show `Up (healthy)`.\n\nNow pull a model that fits your VPS memory directly inside the Ollama container. For a fast smoke test on any 4 GB+ server, start with `llama3.2:3b`; on 12 GB+ servers, pull a 7B/8B model such as `qwen2.5:7b`:\n\n```\nsudo docker compose exec ollama ollama pull llama3.2:3b\n```\n\nOn a 12 GB+ VPS:\n\n```\nsudo docker compose exec ollama ollama pull qwen2.5:7b\n```\n\nVerify the downloaded model and run a quick CLI check before opening the browser:\n\n```\nsudo docker compose exec ollama ollama list\nsudo docker compose exec ollama ollama run llama3.2:3b \"Reply in one short sentence: is the server working?\"\n```\n\nCheck the HTTPS health endpoint through Caddy:\n\n```\ncurl -fsS https://ia.example.com/health\n```\n\nYou should get `{\"status\":true}`. Next:\n\n`https://ia.example.com` in your browser and register the first user — Open WebUI automatically grants `ENABLE_SIGNUP=false` in `open-webui`:\n\n```\nsed -i 's/^ENABLE_SIGNUP=true$/ENABLE_SIGNUP=false/' .env\nsudo docker compose up -d open-webui\n```\n\nVerify that no internal port leaked onto public host interfaces:\n\n```\nsudo ss -tulpn | grep -E ':(80|443|8080|11434)\\b'\n```\n\nOnly ports `80` and `443` should be listening publicly.\n\nTo call your local models from workflows or another server without opening port `11434`:\n\n`http://ollama:11434`.` https://ia.example.com/api/chat/completions` with `Authorization: Bearer <your-key>`. Every external request stays encrypted and authenticated through Caddy and Open WebUI.\nYou do not need to back up `ollama_data` (multi-gigabyte model weights can be re-downloaded with `ollama pull`). Back up `.env` (which holds `WEBUI_SECRET_KEY`) and `open_webui_data` (users, chats, prompts and RAG collections):\n\n```\ncd ~/ollama-webui\n(umask 077 && cp .env open-webui-env-$(date +%F))\nsudo docker compose stop open-webui\nsudo docker run --rm -v ollama-webui_open_webui_data:/data:ro -v \"$PWD\":/backup alpine tar czf /backup/open-webui-data-$(date +%F).tar.gz -C /data .\nsudo docker compose start open-webui\n```\n\nCopy both files off the VPS regularly.\n\n`OLLAMA_VERSION` or `OPEN_WEBUI_VERSION` in \n\n```\ncd ~/ollama-webui\nsudo docker compose pull\nsudo docker compose up -d\nsudo docker compose ps\n```\n\n`sudo docker compose logs --tail=50 open-webui`. On `WEBUI_AUTH` is enabled.`OLLAMA_BASE_URL=http://ollama:11434` matches the Compose service name and run `sudo docker compose exec ollama ollama list` to confirm at least one model is pulled.`OOMKilled`:` sudo docker inspect --format '{{.State.OOMKilled}}' ollama-webui-ollama-1`, lower `OLLAMA_CONTEXT_LENGTH` to `2048` or switch to a smaller model (`3b` on 4–8 GB; `7b`/` 8b` on 12 GB+).`OLLAMA_KEEP_ALIVE=30m` or `-1`, while keeping Originally published at [https://nuvits.net/en/blog/install-ollama-open-webui-linux-vps](https://nuvits.net/en/blog/install-ollama-open-webui-linux-vps)", "url": "https://wpnews.pro/news/how-to-install-ollama-and-open-webui-on-a-linux-vps", "canonical_source": "https://dev.to/nuvits/how-to-install-ollama-and-open-webui-on-a-linux-vps-2p3p", "published_at": "2026-11-30 10:40:50+00:00", "updated_at": "2026-11-30 10:44:24.712794+00:00", "lang": "en", "topics": ["ai-tools", "large-language-models", "ai-infrastructure", "developer-tools"], "entities": ["Ollama", "Open WebUI", "Ubuntu", "Docker", "Caddy", "n8n"], "also_reported_by": [], "takeaway": "On a CPU-only VPS, budget roughly 5-6 GB of RAM for a 4-bit 8B model's weights plus KV cache and the Open WebUI backend, so 12 GB leaves headroom to avoid OOM kills, and never publish Ollama's unauthenticated port 11434 on 0.0.0.0.", "recommendation": {"advice": "Keep Ollama's port 11434 on the private Docker network behind Caddy, and size VPS RAM at 12 GB or more for 7B-8B 4-bit models to avoid OOM kills.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/how-to-install-ollama-and-open-webui-on-a-linux-vps", "markdown": "https://wpnews.pro/news/how-to-install-ollama-and-open-webui-on-a-linux-vps.md", "text": "https://wpnews.pro/news/how-to-install-ollama-and-open-webui-on-a-linux-vps.txt", "jsonld": "https://wpnews.pro/news/how-to-install-ollama-and-open-webui-on-a-linux-vps.jsonld"}}