Skip to main content

Configuration

Ollama configuration is managed through environment variables and configuration files. The primary configuration affects model storage location, server binding, and resource allocation.

Basic Configuration​

1.Set environment variables for basic configuration:


Bash

export OLLAMA_HOST=0.0.0.0:11434
export OLLAMA_MODELS=/usr/share/ollama/.ollama/models

2.Create a configuration directory:


Bash
sudo mkdir -p /etc/ollama
Ubuntu-specific Configuration

3.Configure the systemd service with custom environment variables:

Bash


sudo systemctl edit ollama

4.Add configuration in the override file:


ini


[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_MODELS=/var/lib/ollama/models"
Environment="OLLAMA_KEEP_ALIVE=5m"

5.Set up log rotation:


Bash


sudo tee /etc/logrotate.d/ollama > /dev/null <<EOF
/var/log/ollama/*.log {
daily
missingok
rotate 52
compress
notifempty
create 644 ollama ollama
}
EOF
RHEL8-specific Configuration

6.Configure firewall rules for RHEL8:


Bash


sudo firewall-cmd --permanent --add-port=11434/tcp
sudo firewall-cmd --reload

7.Set SELinux policies:


Bash

sudo setsebool -P httpd_can_network_connect 1
sudo semanage port -a -t http_port_t -p tcp 11434

8.Configure resource limits:


Bash
sudo tee /etc/security/limits.d/ollama.conf > /dev/null <<EOF
ollama soft nofile 65536
ollama hard nofile 65536
ollama soft nproc 4096
ollama hard nproc 4096
EOF