Linux - Installation Ollama
Un guide complet étape par étape pour installer Ollama sur Debian 12 avec un reverse proxy Apache2, le chiffrement SSL et l'authentification HTTP Basic pour un usage d'API publique sécurisé.
Notes Importantes
Veuillez noter ces points importants avant l'installation
Accès Root Requis
L'accès root ou les permissions sudo sont requis pour toutes les étapes d'installation
Domaine Requis
Un domaine valide avec configuration DNS est nécessaire pour les certificats SSL
Configuration du Pare-feu
Ouvrez les ports 80 et 443 dans votre pare-feu pour l'accès HTTP/HTTPS
Mot de Passe Sécurisé
Utilisez un mot de passe fort pour l'authentification API
Créer une Sauvegarde
Sauvegardez tous les fichiers de configuration avant de faire des changements importants
Exigences Matérielles
Au moins 8Go de RAM sont recommandés pour exécuter les modèles Ollama
Étapes d'Installation
Update package lists again
apt update -y && apt upgrade -yInstall basic packages
apt install sudo curlDownload 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 ollamaInstall 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 apache2Install 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-emailCreate 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
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 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.
Dépannage
Problèmes courants et leurs solutions
Installation Terminée !
Votre serveur Ollama est maintenant entièrement configuré et sécurisé avec HTTPS et l'authentification Basic. Vous pouvez maintenant accéder à l'API en toute sécurité.