Linux 启动ollama服务报错:Failed to restart ollama.service: Unit ollama.service not found.
which ollama
sudo tee /etc/systemd/system/ollama.service <<EOF [Unit] Description=Ollama Service After=network-online.target [Service] ExecStart=$(which ollama) serve User=$USER Restart=always RestartSec=3 Environment="PATH=$PATH" Environment="OLLAMA_HOST=0.0.0.0:11434" # 可选:自定义监听地址 [Install] WantedBy=default.target EOF
sudo systemctl daemon-reload
sudo systemctl enable ollama
sudo systemctl start ollama
sudo systemctl status ollama
正常输出应显示active (running)。
curl -fsSL https://ollama.com/install.sh | sh
sudo chmod 644 /etc/systemd/system/ollama.service
路径错误:若which ollama返回空,需手动指定路径:
ExecStart=/usr/local/bin/ollama serve # 替换为实际路径
日志查看:
journalctl -u ollama -n 50 --no-pager
5. 卸载后重装(终极方案)
sudo rm -f /etc/systemd/system/ollama.service sudo rm -f $(which ollama) curl -fsSL https://ollama.com/install.sh | sh
                    
                
                
            
        
浙公网安备 33010602011771号