TürkiyeVPS

How to Install Ollama: Run Your Own AI Model on a VPS

Run open-source language models such as Llama, Qwen and Gemma on your own Linux server with Ollama: installation, choosing a model and how much RAM you need, using the API, secure access over an SSH tunnel and connecting it to n8n.

9 min read

Subscribing to a cloud service is not the only way to use AI models. Ollama is a free tool that downloads open-source language models such as Llama, Qwen, Gemma and Mistral with a single command and runs them on your own server. Your data never leaves your server, you don't pay per request, and your applications reach the model through an API. In this guide we install Ollama on a server running Ubuntu 24.04, pick the right model and connect it to tools like n8n.

Summary: install Ollama with curl -fsSL https://ollama.com/install.sh | sh, then download and try a small model with a command such as ollama run qwen2.5:3b. By default Ollama is only reachable from inside the server (127.0.0.1:11434); don't expose that address to the internet and connect from outside over an SSH tunnel. On servers without a graphics card, RAM and the number of CPU cores are what matter.

What is Ollama good for?

  • Privacy: If you want to summarize customer emails, classify documents or process internal messages, the data is not sent to a third-party company.
  • Fixed cost: There is no per-token billing; apart from the server's monthly fee there are no extra costs.
  • Independence from access restrictions: Some cloud AI services are not available from certain countries. When the model runs on your own server, that problem disappears.
  • Easy integration: Ollama offers a REST API and an OpenAI-compatible endpoint; most libraries and automation tools can connect directly.

Does it work without a graphics card? How much RAM do you need?

Yes. If Ollama finds no graphics card (GPU), it runs the model on the CPU. Answers are not as fast as on a GPU, but small models are perfectly usable for summarizing, classifying, proofreading and simple chat. Roughly:

Model size Examples Download size (approx.) Recommended RAM
0.5–1.5 billion parameters qwen2.5:0.5b, qwen2.5:1.5b, llama3.2:1b 0.4–1.3 GB 2 GB
3 billion parameters qwen2.5:3b, llama3.2:3b ~2 GB 4 GB
7–8 billion parameters qwen2.5:7b, llama3.1:8b 4.5–5 GB 8 GB
14 billion parameters qwen2.5:14b ~9 GB 16 GB

While generating, the whole model is loaded into RAM; remember that the system and your other applications also need memory. If you have less RAM than the model needs, Ollama either won't load it or falls back to swap and becomes very slow. Plan disk space too: each model takes several GB.

For speed, the number of CPU cores matters. On a server whose cores are shared with other customers, answers can slow down noticeably at peak hours; if you'll use it regularly, choose a server with dedicated vCPUs.

1. Prepare the server

Connect to your server over SSH and update the packages:

sudo apt update && sudo apt upgrade -y

Ollama runs much faster when it can use the CPU's AVX2 instruction set. Check that your processor supports it:

grep -o -m1 avx2 /proc/cpuinfo

If you see avx2 in the output, you're fine. If RAM is tight on your server you can add swap as a small safety margin; but swap does not replace missing RAM, it only keeps the server from crashing on sudden spikes.

2. Install Ollama

The official install script downloads Ollama, creates a system user called ollama and starts it as a systemd service:

curl -fsSL https://ollama.com/install.sh | sh

When it finishes, check that the service is running:

systemctl status ollama
ollama --version

If the script finds no GPU it prints a warning and continues in CPU mode; this is normal.

3. Download and try your first model

Let's start with a small multilingual model:

ollama run qwen2.5:3b

On the first run the model is downloaded, then a chat prompt opens. Type a question; type /bye to exit. Common commands:

Command What it does
ollama pull MODEL Downloads a model without running it
ollama list Lists downloaded models and their sizes
ollama ps Shows the models currently loaded in memory
ollama rm MODEL Deletes a model and frees disk space
ollama show MODEL Shows model details (parameters, context length)

If you need answers in Turkish, Russian or Persian, test a few models with your own sample tasks. In general larger models write more naturally in these languages; 1–3 billion parameter models do better at short, well-defined tasks (summaries, classification, draft translations). The current model list is at ollama.com/library.

4. Use the API

Inside the server Ollama provides a REST API on port 11434. You can send a request from an application or a script like this:

curl http://127.0.0.1:11434/api/generate -d '{
  "model": "qwen2.5:3b",
  "prompt": "What is a VPS? Explain in two sentences.",
  "stream": false
}'

An OpenAI-compatible endpoint is also available. An application that uses the OpenAI library can be pointed at Ollama just by changing its address:

curl http://127.0.0.1:11434/v1/chat/completions -H "Content-Type: application/json" -d '{
  "model": "qwen2.5:3b",
  "messages": [{"role": "user", "content": "Hello!"}]
}'

In Python, for example, OpenAI(base_url="http://127.0.0.1:11434/v1", api_key="ollama") is enough (the key is a required field, so any value works; Ollama doesn't check it). To keep Python applications running permanently on the server, see our guide to running a Python application on a VPS.

5. Security: don't expose the API to the internet

The Ollama API has no authentication. If you open port 11434 to the internet, anyone who finds the address can use your model, keep your CPU busy and download or delete models. So:

  • Leave Ollama on its default setting (127.0.0.1).
  • Don't open port 11434 in the firewall. If you use UFW, allowing only SSH is enough.
  • If you need access from your own computer, use an SSH tunnel:
ssh -L 11434:127.0.0.1:11434 user@SERVER_IP

While this connection is open, http://127.0.0.1:11434 on your computer reaches Ollama on the server, and the traffic is encrypted by SSH. To harden the server in general, follow our Linux server security guide.

6. Settings: how long a model stays in memory and parallel requests

Ollama's behaviour is controlled with environment variables. To edit the service settings:

sudo systemctl edit ollama

Add, for example:

[Service]
Environment="OLLAMA_KEEP_ALIVE=30m"
Environment="OLLAMA_NUM_PARALLEL=1"
Environment="OLLAMA_MAX_LOADED_MODELS=1"
  • OLLAMA_KEEP_ALIVE: how long the model stays in RAM after the last request. The default is 5 minutes; if you use it often, a longer value avoids reloading the model for every request.
  • OLLAMA_NUM_PARALLEL: how many requests are processed at once. Keep it at 1 on servers with little RAM.
  • OLLAMA_MAX_LOADED_MODELS: how many models are kept in RAM at the same time.

Save and restart the service:

sudo systemctl daemon-reload
sudo systemctl restart ollama

7. Connect it to n8n

One of the most practical uses of Ollama is as an AI step in n8n workflows: summarizing incoming email, classifying form responses, drafting replies to Telegram messages and so on. In n8n you add the Ollama Chat Model node and enter Ollama's address as the base URL.

  • If n8n is installed directly on the server, the address is http://127.0.0.1:11434.
  • If n8n runs inside Docker, the container cannot reach the server's 127.0.0.1. In that case make Ollama listen on all interfaces (sudo systemctl edit ollama with Environment="OLLAMA_HOST=0.0.0.0:11434"), add extra_hosts: ["host.docker.internal:host-gateway"] to n8n's compose file and use http://host.docker.internal:11434 as the address in n8n. In the firewall, open port 11434 only to Docker networks, never to the internet:
sudo ufw allow from 172.16.0.0/12 to any port 11434 proto tcp

You can check your Docker networks' address ranges with docker network inspect bridge and docker network ls. If you haven't installed Docker yet, start with our Docker installation on Ubuntu 24.04 guide.

Updating and removing Ollama

To update, simply run the install command again; your downloaded models are kept:

curl -fsSL https://ollama.com/install.sh | sh

By default models are stored in /usr/share/ollama/.ollama/models. If the disk starts filling up, find unused models with ollama list and remove them with ollama rm.

TürkiyeVPS servers for Ollama

Running Ollama efficiently on a CPU needs dedicated cores and enough RAM. Our VDS plans are in Istanbul and come with dedicated vCPUs on an Intel Core i5-10400F, guaranteed RAM, unmetered speed, 3 TB of traffic per month and root access. For 3-billion-parameter models VDS Pro with 4 GB RAM is a good start, and for 7–8-billion-parameter models VDS Ultra with 8 GB RAM; for larger models and several simultaneous users, look at the VDS Enterprise plans with 12–48 GB RAM. Payments are accepted in USDT (TRC20).

Frequently Asked Questions

Is Ollama free?

Yes. Ollama is open source and free, and most models can be downloaded for free as well. Each model has its own license; check it before commercial use. You only pay for the server.

How fast is Ollama on a VPS without a graphics card?

Speed depends on the model size, the number of cores and the processor. Small models (1–3 billion parameters) answer short tasks at a usable speed on a server with a few cores; 7–8-billion-parameter models are noticeably slower. For long text generation and multi-user chat, a server with a GPU is a better fit.

Which port does Ollama use? How do I connect from outside?

Ollama uses port 11434 and by default is only reachable from inside the server. Because the API has no authentication, don't open this port to the internet; connect from your own computer through an SSH tunnel with ssh -L 11434:127.0.0.1:11434 user@SERVER_IP.

Can I use a ChatGPT-like web interface with Ollama?

Yes. Interfaces such as OpenWebUI connect to Ollama and let you chat from the browser. If you expose that interface to the internet, you need a strong admin password, HTTPS and sign-up disabled.

I get a "model requires more system memory" error. What should I do?

It means the model doesn't fit into the server's free RAM. Choose a smaller model (for example qwen2.5:3b instead of qwen2.5:7b), check with ollama ps whether another model is still in memory, or move to a plan with more RAM.