Linux - Ollama Installation
En ëmfassenden Schrëtt-fir-Schrëtt Guide fir Ollama op Debian 12 ze installéieren mat Apache2 Reverse Proxy, SSL-Verschlësselung an HTTP Basic Authentication fir sécher ëffentlech API-Notzung.
Setup Schrëtt
Install Dependencies
Installation of required system packages and dependencies for Ollama and Apache2.
Update package lists again
apt update -y && apt upgrade -yInstall basic packages
apt install sudo curlInstall Ollama
Installation of Ollama and initial configuration with a test model.
Download and install Ollama
curl -fsSL https://ollama.com/install.sh | shDownload and test small test model
ollama run gemma3:4bOpen Ollama service configuration
systemctl edit ollama.serviceAdd the following environment variables
Reload systemd manager
sudo systemctl daemon-reexecReload Ollama service
sudo systemctl daemon-reloadRestart Ollama service
sudo systemctl restart ollamaConfigure Apache2
Installation and configuration of Apache2 as reverse proxy for Ollama.
Install Apache2 and SSL modules
sudo apt update && sudo apt install apache2 apache2-utils -yEnable required Apache modules
sudo a2enmod proxy proxy_http ssl headers rewriteRestart Apache2
sudo systemctl restart apache2Setup SSL Certificate
Setting up Let's Encrypt SSL certificates for secure HTTPS connections.
Install Certbot for Let's Encrypt
sudo apt install certbot python3-certbot-apache -yRequest SSL certificate for domain
sudo certbot --apache -d server.chad.lu --register-unsafely-without-emailHTTP Basic Authentication
Configuration of HTTP Basic Authentication for secure API access.
Create directory for auth files
sudo mkdir -p /etc/apache2/htpasswdCreate user with password for HTTP Basic Auth
sudo htpasswd -c /etc/apache2/htpasswd/ollama-api.htpasswd apiuserEnter a secure password when prompted
Enable Virtual Host
Enabling the Virtual Host and restarting Apache services.
Create the Apache Virtual Host configuration file
Enable new site configuration
sudo a2ensite server.chad.lu.confDisable default Apache site
sudo a2dissite 000-default.confDisable default SSL site
sudo a2dissite 000-default-le-ssl.confReload Apache configuration
sudo systemctl reload apache2Test Installation
Verification of the installation and testing API functionality.
Test API endpoint with curl
curl -u apiuser https://server.chad.lu/ollama/api/generate -H "Content-Type: application/json" -d '{"model": "gemma3:4b", "prompt": "Erzähl mir eine Geschichte.", "stream": true}'You will be prompted for the 'apiuser' password. On successful test, you will receive JSON responses with generated text fragments.
Problemléisung
Heefeg Problemer an hir Léisungen
Ollama Issues
Check which service is running on port 11434
sudo ss -tulpen | grep 11434Check Ollama service status
sudo systemctl status ollamaShow Ollama service logs
sudo journalctl -u ollama -fApache Issues
Test Apache configuration
sudo apache2ctl configtestCheck Apache service status
sudo systemctl status apache2Show Apache error logs
sudo tail -f /var/log/apache2/error.logSSL Issues
List all Certbot certificates
sudo certbot certificatesTest certificate renewal
sudo certbot renew --dry-runTest SSL connection with OpenSSL
openssl s_client -connect server.chad.lu:443