[GH-ISSUE #3516] [Linux] Switch systemd service unit to EnvironmentFile and start providing it in the repository instead #2168

Open
opened 2026-04-12 12:25:01 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @C0rn3j on GitHub (Apr 6, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/3516

What are you trying to do?

Run Llama service on Linux via systemd and being able to configure it without unit overrides through a configuration file.

How should we solve this?

Stop using Environment, use EnvironmentFile instead in cb03fc9571/scripts/install.sh (L100-L116)

https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#EnvironmentFile=

Edit documentation accordingly - https://github.com/ollama/ollama/blob/main/docs/faq.md#setting-environment-variables-on-linux

Stop carrying the unit file in install.sh, add it to the repository, this allows distributions to cleanly package the unit.

Download the new configuration file as /etc/ollama.conf.example and if /etc/ollama.conf does not exist, copy the example there, otherwise keep user configuration intact.

[Service]
EnvironmentFile=/etc/ollama.conf

This also allows for having all of the options in the configuration neatly visible, instead of having to wade through help/documentation for simple things.

Example config of mine:

# /etc/ollama.conf

# The host:port to bind to (default "127.0.0.1:11434")
OLLAMA_HOST=0.0.0.0:11434           

# A comma separated list of allowed origins.
OLLAMA_ORIGINS=*://localhost,*://192.168.1.40,*://192.168.1.10

# The path to the models directory (default is "~/.ollama/models")
OLLAMA_MODELS=/models/ollama

HOME=/var/lib/ollama
GIN_MODE=release

What is the impact of not solving this?

Distribution packaging is hard and configuration of ollama has to be done by overriding systemd units.

Anything else?

Adapting hardening from the Arch Linux unit might be a good idea, already saw people in this repository trying to give Ollama permissions to their home folders which the unit prevents.

7418e63fb8/ollama.service

Originally created by @C0rn3j on GitHub (Apr 6, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/3516 ### What are you trying to do? Run Llama service on Linux via systemd and being able to configure it without unit overrides through a configuration file. ### How should we solve this? Stop using `Environment`, use `EnvironmentFile` instead in https://github.com/ollama/ollama/blob/cb03fc9571814edd5af1109bf1a562e813ecb816/scripts/install.sh#L100-L116 https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#EnvironmentFile= Edit documentation accordingly - https://github.com/ollama/ollama/blob/main/docs/faq.md#setting-environment-variables-on-linux Stop carrying the unit file in install.sh, add it to the repository, this allows distributions to cleanly package the unit. Download the new configuration file as `/etc/ollama.conf.example` and if /etc/ollama.conf does not exist, copy the example there, otherwise keep user configuration intact. ```systemd [Service] EnvironmentFile=/etc/ollama.conf ``` This also allows for having all of the options in the configuration neatly visible, instead of having to wade through help/documentation for simple things. Example config of mine: ```shell # /etc/ollama.conf # The host:port to bind to (default "127.0.0.1:11434") OLLAMA_HOST=0.0.0.0:11434 # A comma separated list of allowed origins. OLLAMA_ORIGINS=*://localhost,*://192.168.1.40,*://192.168.1.10 # The path to the models directory (default is "~/.ollama/models") OLLAMA_MODELS=/models/ollama HOME=/var/lib/ollama GIN_MODE=release ``` ### What is the impact of not solving this? Distribution packaging is hard and configuration of ollama has to be done by overriding systemd units. ### Anything else? Adapting hardening from the Arch Linux unit might be a good idea, already saw people in this repository trying to give Ollama permissions to their home folders which the unit prevents. https://gitlab.archlinux.org/archlinux/packaging/packages/ollama/-/blob/7418e63fb87fd43277a6051466325081680d1627/ollama.service
Author
Owner

@cutlery commented on GitHub (Feb 22, 2026):

+1

<!-- gh-comment-id:3941635148 --> @cutlery commented on GitHub (Feb 22, 2026): +1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#2168