[Unit] Description=Ollama Service Documentation=https://github.com/ollama/ollama After=network-online.target Wants=network-online.target [Service] Type=simple User=ollama Group=ollama ExecStart=/usr/bin/ollama serve Restart=always RestartSec=3 Environment="OLLAMA_HOST=0.0.0.0:11434" Environment="OLLAMA_MODELS=/var/lib/ollama" # Security hardening NoNewPrivileges=true PrivateTmp=true ProtectSystem=strict ProtectHome=true ReadWritePaths=/var/lib/ollama /var/log/ollama ProtectKernelTunables=true ProtectKernelModules=true ProtectControlGroups=true RestrictRealtime=true RestrictNamespaces=true LockPersonality=true MemoryDenyWriteExecute=false RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 SystemCallFilter=@system-service SystemCallErrorNumber=EPERM # Logging StandardOutput=append:/var/log/ollama/ollama.log StandardError=append:/var/log/ollama/ollama-error.log [Install] WantedBy=multi-user.target