How to install Ollama on a VPS
Run your own open-source LLM on a server you control. This walks through it end to end, from a fresh VPS to a working API, in about 15 minutes.
Ollama is the simplest way to run open-source language models yourself. It downloads a model, runs it, and exposes an OpenAI-compatible API, all from one command. Best of all, small and mid-size models run on an ordinary CPU VPS, so you do not need a GPU to get started.
By the end of this guide you will have a model like Llama 3.1 or Mistral answering requests on your own server. For a full picture of which models fit which plan, see what open-source AI runs on a VPS.
What you need
- A Linux VPS. We recommend a KVM VPS with at least 8 GB of RAM for a 7B or 8B model. KVM is best because you get full control and can add Docker later.
- Ubuntu 22.04 or 24.04 (these steps work on most Debian-based systems).
- Root or sudo access over SSH.
Step 1: Provision a VPS
Start with a KVM VPS sized for the model you want. An 8 GB plan comfortably runs a 7B or 8B model. If you only need a small model, 4 GB is enough; for bigger models or several at once, size up. See the what runs on each VPS size table to match a model to a plan, and pick one on the VPS plans page.
Step 2: Connect over SSH and update
Log in to your server and bring it up to date. Replace the address with your server's IP.
ssh root@YOUR_SERVER_IP
apt update && apt upgrade -yStep 3: Install Ollama
Ollama provides an official install script. One command installs it and sets it up as a background service.
curl -fsSL https://ollama.com/install.sh | shWhen it finishes, confirm it is installed:
ollama --versionStep 4: Download and run a model
Pull and run a model in one step. The first run downloads the model, which can take a few minutes depending on its size.
ollama run llama3.1You will drop into an interactive prompt. Type a question, and type /bye to exit. Prefer a different model? Try ollama run mistral or a smaller, faster option like ollama run llama3.2:3b.
Step 5: Use the API
Ollama runs a local API on port 11434. Test it with a simple request:
curl http://localhost:11434/api/generate -d '{
"model": "llama3.1",
"prompt": "Explain what a VPS is in one sentence.",
"stream": false
}'You will get a JSON response with the model's answer. Because the API is OpenAI-compatible, most existing tools and libraries can point at your server with only a base-URL change.
Security first. By default Ollama listens on localhost only, which is what you want. Do not expose port 11434 to the public internet without protection. If you need remote access, put it behind a firewall and a reverse proxy such as Nginx or Caddy with authentication and HTTPS.
Step 6: Add a private ChatGPT UI (optional)
For a friendly web interface, run Open WebUI with Docker. On a KVM VPS with Docker installed, this one command starts it and connects it to the Ollama you just set up:
docker run -d -p 3000:8080 \
--add-host=host.docker.internal:host-gateway \
-v open-webui:/app/backend/data \
--name open-webui --restart always \
ghcr.io/open-webui/open-webui:mainThen open http://YOUR_SERVER_IP:3000, create the first account, and you have your own private chat interface. Put it behind HTTPS before real use.
What to run next
With Ollama in place you can build on it: connect it to n8n for AI automation, add a vector database like Qdrant for retrieval-augmented generation, or run several models at once on a larger plan. If responses feel slow, that is CPU inference at work. Expect roughly 4 to 15 tokens per second for a 7B or 8B model, which suits personal tools and low-traffic APIs. For heavier needs, size up your VPS.
Ollama on a VPS, answered.
Do I need a GPU to run Ollama?
How much RAM do I need?
Which model should I start with?
Is CPU inference fast enough?
Ready to run your own AI?
See what runs on each VPS size, then start on a KVM plan built for it.