diff --git a/docs/faq.md b/docs/faq.md index 0dbbb3ff..d7d7ff5b 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -73,23 +73,17 @@ If Ollama is run as a macOS application, environment variables should be set usi ### Setting environment variables on Linux -If Ollama is run as a systemd service, environment variables should be set using `systemctl`: +If Ollama is run as a systemd service, environment variables should be set via the file specified in the `EnvironmentFile` option of the systemd unit: -1. Edit the systemd service by calling `systemctl edit ollama.service`. This will open an editor. - -2. For each environment variable, add a line `Environment` under section `[Service]`: +1. Edit the file `/etc/ollama/serve.conf`: ```ini - [Service] - Environment="OLLAMA_HOST=0.0.0.0" + OLLAMA_HOST=0.0.0.0 ``` -3. Save and exit. - -4. Reload `systemd` and restart Ollama: +2. Restart Ollama: ```bash - systemctl daemon-reload systemctl restart ollama ``` diff --git a/docs/linux.md b/docs/linux.md index 0eec014f..4e7349df 100644 --- a/docs/linux.md +++ b/docs/linux.md @@ -129,7 +129,7 @@ sudo tar -C /usr -xzf ollama-linux-amd64.tgz ## Installing specific versions -Use `OLLAMA_VERSION` environment variable with the install script to install a specific version of Ollama, including pre-releases. You can find the version numbers in the [releases page](https://github.com/ollama/ollama/releases). +Use `OLLAMA_VERSION` environment variable with the install script to install a specific version of Ollama, including pre-releases. You can find the version numbers in the [releases page](https://github.com/ollama/ollama/releases). For example: @@ -168,3 +168,8 @@ sudo rm -r /usr/share/ollama sudo userdel ollama sudo groupdel ollama ``` + +Remove the config +```bash +sudo rm -rf /etc/ollama +``` diff --git a/scripts/install.sh b/scripts/install.sh index 79a7b564..a94fcd45 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -119,6 +119,18 @@ configure_systemd() { status "Adding current user to ollama group..." $SUDO usermod -a -G ollama $(whoami) + if $SUDO test -f "/etc/ollama/serve.conf" ; then + status "Skip creating ollama serve config file..." + else + status "Creating ollama serve config file..." + $SUDO mkdir -p /etc/ollama/ + cat </dev/null +# The list of supported env variables could be found by running: ollama serve --help +#OLLAMA_DEBUG=1 +#OLLAMA_HOST=0.0.0.0:11434 +EOF + fi + status "Creating ollama systemd service..." cat </dev/null [Unit] @@ -132,6 +144,7 @@ Group=ollama Restart=always RestartSec=3 Environment="PATH=$PATH" +EnvironmentFile=/etc/ollama/serve.conf [Install] WantedBy=default.target