How to Install Ollama on a Linux VPS and Run Local AI

How to Install Ollama on a Linux VPS and Run Local AI

Ollama is an application that allows you to run Large Language Models (LLM) locally without relying on cloud-based AI services like OpenAI or Gemini.

With Ollama, you can try various open-source AI models such as Llama, DeepSeek, Qwen, Gemma, and others directly from your VPS.

In this tutorial, we will discuss how to install Ollama on a Linux VPS, run your first AI model, and enable API access so it can be used by other applications.

Preparation Before Installing Ollama

This tutorial was tested using a Debian 13 VPS with the following specifications

  • 2 vCPU
  • 2GB RAM
  • 65GB SSD

The VPS used is from Vultr. If you do not have a VPS yet, you can register for an account at vultr.com and have the opportunity to get a $300 trial credit for 30 days.

How to Install Ollama on a Linux VPS and Run Local AI

If you already have a VPS or want to try it locally, you can start the steps for How to Install Ollama on a Linux VPS and Run Local AI below.

1. Update System Packages

Before installing Ollama, it is best to update the packages on your VPS.

sudo apt update && sudo apt upgrade -y
Cara Install Ollama di VPS Linux dan Menjalankan AI Lokal - WPGan.com - 1

2. Install Ollama

Install Ollama using the official script from Ollama

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

Next, ensure that Ollama is running on your VPS

systemctl status ollama

If it is running, the service status will display the following active (running).

Cara Install Ollama di VPS Linux dan Menjalankan AI Lokal - WPGan.com - 2

3. Run Your First AI Model

As an example, we will use the model Llama 3.2 1B which is relatively lightweight and suitable for a VPS with 2 GB of RAM. For other models, you can check them on the Models on Ollama.

ollama run llama3.2:1b

When run for the first time, Ollama will download the model you want to use. Wait until the download process is complete, and afterward, you can immediately try providing a prompt, for example:

Jelaskan apa itu WordPress dalam satu kalimat.
Cara Install Ollama di VPS Linux dan Menjalankan AI Lokal - WPGan.com - 3

After you are done, you can close the session by sending the message /bye or by clicking the button CTRL + D.

4. Enabling the Ollama API

By default, the Ollama API can only be accessed from localhost, or on the VPS itself. If you want to access the API from another computer or an external application, change the Ollama service configuration.

sudo systemctl edit ollama

Inside the file editor, add the following line

[Service]Environment="OLLAMA_HOST=0.0.0.0:11434"
Cara Install Ollama di VPS Linux dan Menjalankan AI Lokal - WPGan.com - 4-1

Save the file, then restart the service.

sudo systemctl daemon-reloadsudo systemctl restart ollama

Ensure that Ollama is listening on all network interfaces.

ss -tulpn | grep 11434

If successful, the result will display the address *:11434.

Cara Install Ollama di VPS Linux dan Menjalankan AI Lokal - WPGan.com - 4-2

This configuration allows the Ollama API to be accessed over the network. If the server is used in a production environment, you should restrict access using a firewall or reverse proxy so it cannot be accessed by just anyone.

5. Allow Firewall (Optional)

If your VPS uses UFW, make sure to allow access to port 11434.

sudo ufw allow 11434/tcp

If you only want to allow a specific IP, use the following command:

sudo ufw allow from IP_ADDRESS to any port 11434 proto tcp

Replace IP_ADDRESS with the IP address allowed to access the Ollama API.

Cara Install Ollama di VPS Linux dan Menjalankan AI Lokal - WPGan.com - 5

6. Test the Ollama API

Now try accessing the API using another computer. For example, if you installed Ollama on a VPS, you can run this command on your local PC:

curl http://IP_VPS:11434/api/generate -d '{ "model": "llama3.2:1b", "prompt": "Jelaskan apa itu WordPress dalam satu kalimat.", "stream": false }'

If successful, the API will return data in JSON format, for example like this

Cara Install Ollama di VPS Linux dan Menjalankan AI Lokal - WPGan.com - 6

Those are the steps you can try to install Ollama on a Linux VPS and run local AI.

Usage Notes for a 2 GB RAM VPS

Based on testing performed on a VPS with 2 vCPU and 2 GB of RAM, small AI models can still run quite well. Models that ran smoothly:

  • llama3.2:1b
  • deepseek-coder:1.3b

Meanwhile, larger models began to experience performance degradation.

  • qwen3.5:2b can still be run, but the response is very slow.
  • qwen3:4b already exhausted the RAM and swap, making it unsuitable for use.
  • deepseek-r1:7b very slow or even unresponsive and completely unsuitable for use.

If you are also using a VPS with 2 GB of RAM, it is best to use models around 1B to 1.5B in size or models with a file size under 2 GB to keep them responsive.

Conclusion

Ollama is a very practical solution if you want to run AI locally on a VPS or a private server. The installation process is relatively simple, and you can immediately try various AI models with just a few commands.

However, model selection still needs to be adjusted to the specifications of the VPS being used. For a VPS with 2 GB of RAM, lightweight models like Llama 3.2 1B or DeepSeek Coder 1.3B are more ideal choices compared to large-sized models.

FAQ

Can Ollama be installed on a VPS with 2 GB of RAM?

Yes. Based on the testing in this tutorial, Ollama can run well on a 2 GB RAM VPS using small AI models like Llama 3.2 1B and DeepSeek Coder 1.3B.

Why is the first request slower than subsequent requests?

When used for the first time, Ollama needs to load the model from storage into RAM. After the model is successfully loaded, subsequent requests are usually processed faster as long as the model remains in memory.

How do I see the models that have been installed?

Use the following command.

ollama list

How do I delete an Ollama model?

To delete an Ollama model that has been downloaded, you can use the command ollama rm NAMA_MODEL. For example

ollama rm llama3.2:1b

Can Ollama be used by other applications?

Yes. Ollama provides a REST API that can be accessed via port 11434, so it can be used by various applications, including code editors, workflow automation, and WordPress plugins that support the OpenAI Compatible API, such as the plugin Koneek.

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...