from any location in shell, run:
curl -fsSL https://ollama.com/install.sh | sh
Do this only if you want to make a dedicated ai server and your network is secure! Better: Take/Build a secure api!
Your ollama server will run totally fine locally, without network listening.
sudo nano /etc/systemd/system/ollama.service
add the following: Environment="OLLAMA_HOST=0.0.0.0"
[Unit]
Description=Ollama Service
After=network-online.target
[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
Environment="OLLAMA_HOST=0.0.0.0" # Add this line to listen on all interfaces
[Install]
WantedBy=default.target
Allow ollama api through firewall:
sudo ufw allow 11434/tcp