Linux - Ollama Installation
A comprehensive step-by-step guide for installing Ollama on Debian 12 with Apache2 reverse proxy, SSL encryption and HTTP Basic Authentication for secure public API usage.
Debian 12OllamaApache2SSL/TLSAPI
Important Notes
Please note these important points before setup
Root Access Required
Root access or sudo permissions are required for all installation steps
Domain Required
Valid domain with DNS configuration is necessary for SSL certificates
Firewall Configuration
Open ports 80 and 443 in your firewall for HTTP/HTTPS access
Secure Password
Use a strong password for API authentication
Create Backup
Backup all configuration files before making important changes
Hardware Requirements
At least 8GB RAM is recommended for running Ollama models
Setup Steps
Update package lists again
Install basic packages
Download and install Ollama
Download and test small test model
Open Ollama service configuration
/etc/systemd/system/ollama.service.d/override.confoverride.conf
Reload systemd manager
Reload Ollama service
Restart Ollama service
Check if Ollama is listening on port 11434
Install Apache2 and SSL modules
Enable required Apache modules
Restart Apache2
Install Certbot for Let's Encrypt
Request SSL certificate for domain
Create directory for auth files
Create user with password for HTTP Basic Auth
Note: Enter a secure password when prompted
/etc/apache2/sites-available/server.chad.lu.confserver.chad.lu.conf
Enable new site configuration
Disable default Apache site
Disable default SSL site
Reload Apache configuration
Test API endpoint with curl
Note: You will be prompted for the 'apiuser' password. On successful test, you will receive JSON responses with generated text fragments.
Troubleshooting
Common issues and their solutions
Installation Complete!
documentations.ollamaSetup.completion.description