Skip to content

AI and language modelsFor advanced usersDuration around 15 min.

How to install Ollama on Ubuntu: run your own LLMs with an API

With Ollama, language models run on your own server โ€” the data does not leave it. This tutorial installs Ollama as a service, loads a first model, calls it via the API and shows how to secure access.

Tested on with Ollama 0.40 on Ubuntu 24.04 LTS and Ubuntu 26.04 LTS

At a glance

  • The installation script creates a dedicated user and a systemd service; Ollama then listens on 127.0.0.1:11434.
  • On a GPU server, Ollama uses NVIDIA cards from driver version 550 โ€” nvidia-smi shows whether the driver is running.
  • For external access, Ollama remains behind a reverse proxy or a firewall; the API does not have its own authentication.

Prerequisites

  • A server with Ubuntu 24.04 or 26.04 and a user with sudo privileges. Small models run on any Cloud Server; for larger models and fast responses, you need a GPU server with an NVIDIA card.
  • Enough space for the models: even small ones take up a few hundred megabytes, large ones several dozen gigabytes.

1. On a GPU server: check the driver

Ollama requires the driver from version 550 for NVIDIA cards. nvidia-smi shows the card and driver version; if the command is missing, install the NVIDIA driver first. With pciutils, the installation script detects the card itself.

Check card and driver
nvidia-smi
sudo apt install -y pciutils

Without a graphics card, you skip this step; Ollama then computes on the processor.

2. Install Ollama

The script downloads Ollama to /usr/local/bin, creates the ollama user and sets up the service, which starts immediately.

Install
curl -fsSL https://ollama.com/install.sh | sh
The most important lines of the output
>>> Adding ollama user to video group...
>>> Adding current user to ollama group...
>>> Creating ollama systemd service...
>>> Enabling and starting ollama service...
Check version and service
ollama -v
systemctl status ollama

3. Load the first model and ask a question

At 291 MB, gemma3:270m is small enough for a first test on any server. You load larger models in exactly the same way โ€” the model library on ollama.com shows which ones are available.

Load, list, ask model
ollama pull gemma3:270m
ollama list
ollama run gemma3:270m "Was ist die Hauptstadt von Frankreich?"

4. Call via the API

Applications call Ollama via HTTP. With stream set to false, the response is returned as a JSON object:

Request to the API
curl http://localhost:11434/api/generate -d '{"model":"gemma3:270m","prompt":"Sag Hallo.","stream":false}'
Response, shortened
{"model":"gemma3:270m","created_at":"2026-12-02T10:39:14Z","response":"Hallo! Wie kann ich Ihnen helfen?\n","done":true, โ€ฆ}

5. Access from other machines

After installation, Ollama only listens on 127.0.0.1. If other machines need to access it, open a drop-in file for the unit with systemctl edit and enter the address:

/etc/systemd/system/ollama.service.d/override.conf
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Create drop-in file and restart
sudo systemctl edit ollama
sudo systemctl daemon-reload
sudo systemctl restart ollama
ss -ltnp | grep 11434

The API has no authentication

Anyone who can reach port 11434 can use, load and delete models. Only open the port for known addresses in the firewall โ€” or leave Ollama on 127.0.0.1 and put an Nginx reverse proxy with TLS and authentication in front of it.

6. Log, running models, clean up

The models are located under /usr/share/ollama/.ollama/models. You can get an update by running the installation script again.

Log, loaded models, delete model
journalctl -u ollama --since today
ollama ps
ollama rm gemma3:270m

Typical errors

  • Unable to detect NVIDIA/AMD GPU: The script cannot find lspci or a card. Install pciutils and check the driver with nvidia-smi; without a card, the message is just a note.
  • Responses very slow: The model does not fit into the graphics memory and runs entirely or partially on the processor. ollama ps shows where it is running; choose a smaller model or a card with more memory.
  • No external access to port 11434: Ollama only listens on 127.0.0.1. Check the drop-in file from step 5 with ss -ltnp.
  • Out of space: Large models fill up the disk quickly. Delete unused ones with ollama rm.

We tested all commands in this guide on 2 December 2026 โ€” with Ollama 0.40 on Ubuntu 24.04 LTS and Ubuntu 26.04 LTS. If a step changes at the manufacturer, we update it here along with the date.

Official documentation

Frequently asked questions about Ollama

Do I need a graphics card for Ollama?

Not necessarily: small models also run on the processor. For larger models and smooth responses, an NVIDIA card with enough graphics memory is the deciding factor.

Does my data leave the server?

No. The model runs on your server; requests and responses do not go to any external service. Only downloading the models requires an outbound connection.

Which port does Ollama run on?

On port 11434, and only on 127.0.0.1 after installation. You change the address with OLLAMA_HOST in the unit.

Where does Ollama store the models?

When installed as a service, under /usr/share/ollama/.ollama/models. A different location can be set with OLLAMA_MODELS.

How do I update Ollama?

Run the installation script again. It replaces the program and leaves the downloaded models in place.

Further reading

More tutorials

  • How to install Docker on Ubuntu: Docker Engine and Compose

    ContainerFor beginnersabout 10 min

    By the end of this tutorial, Docker Engine from the official Docker repository will be running on your Ubuntu server, along with the Compose plugin and a first service. You need a server with Ubuntu 24.04 LTS or 26.04 LTS and a user with sudo privileges.

  • How to set up Nginx as a reverse proxy with HTTPS (Letโ€™s Encrypt)

    Web serverFor beginnersabout 20 min

    Following this tutorial, Nginx will accept requests to your domain, pass them to an application on the same server, and serve everything over HTTPS with a Letโ€™s Encrypt certificate. This is suitable for Node.js, Python, Go, or a container listening on a local port.

  • How to install WordPress on your own server: Nginx, PHP and MariaDB

    Web serverFor advanced usersabout 30 min

    This tutorial brings WordPress to your own server with Ubuntu: Nginx as the web server, PHP-FPM for WordPress, MariaDB as the database and a certificate from Letโ€™s Encrypt. Finally, you will complete the setup in the browser, where you create the title and administrator.

Graphics cards for your models

GPU servers with NVIDIA cards such as L4, L40S and H100 for larger language models.