How do I configure Ollama server?
Ollama server can be configured with environment variables.
Setting environment variables on Mac
If Ollama is run as a macOS application, environment variables should be set using launchctl
:
- For each environment variable, call
launchctl setenv
.launchctl setenv OLLAMA_HOST "0.0.0.0:11434"
- Restart Ollama application.
Setting environment variables on Linux
If Ollama is run as a systemd service, environment variables should be set using systemctl
:
- Edit the systemd service by calling
systemctl edit ollama.service
. This will open an editor. - For each environment variable, add a line
Environment
under section[Service]
:[Service] Environment="OLLAMA_HOST=0.0.0.0:11434"
- Save and exit.
- Reload
systemd
and restart Ollama:
systemctl daemon-reload
systemctl restart ollama
Setting environment variables on Windows
On Windows, Ollama inherits your user and system environment variables.
Start the Ollama application from the Windows Start menu.
First Quit Ollama by clicking on it in the task bar.
Start the Settings (Windows 11) or Control Panel (Windows 10) application and search for environment variables.
Click on Edit environment variables for your account.
Edit or create a new variable for your user account for OLLAMA_HOST
, OLLAMA_MODELS
, etc.
Click OK/Apply to save.
更改用户环境变量,添加
OLLAMA_HOST
值为 0.0.0.0
OLLAMA_KEEP_ALIVE
如果想久一些,简单的方法是-1
,如果不生效,改成一个较大的数值即可,例如1000000
参考:
https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-configure-ollama-server