Deployment Overview of Phi-4-14b on Server¶
Prerequisites and Basic Requirements¶
To ensure the application functions correctly, the following requirements must be met by the host environment:
-
Operating System: Ubuntu (recommended).
-
Privileges: Root or sudo access is required for package installation and service management.
-
Hardware Acceleration: NVIDIA GPU support with CUDA installed is required for hardware acceleration.
-
Network Ports:
-
443: External HTTPS traffic. -
8080: Internal application traffic (Open WebUI). -
11434: Ollama API communication.
FQDN of the final panel on the hostkey.in domain¶
The application is accessible via a specific subdomain template based on your server ID:
| Parameter | Value |
|---|---|
| Prefix | phi |
| Domain | hostkey.in |
| Full template | phi{Server_ID}.hostkey.in |
Application installation process¶
The installation involves several stages to set up the environment, the AI engine, and the web interface:
-
System Preparation: Installation of Docker and NVIDIA CUDA drivers.
-
AI Engine Setup:
-
The Ollama service is installed via a shell script (
curl -fsSL https://ollama.com/install.sh | sh). -
A dedicated
ollamasystem user is created. -
The
ollama.serviceconfiguration is modified to allow remote connections (OLLAMA_HOST=0.0.0.0) and enable Flash Attention (LLAMA_FLASH_ATTENTION=1). -
The
phi4model is pulled via the commandollama pull phi4. -
Web Interface Deployment: The Open WebUI application is deployed as a Docker container using the
ghcr.io/open-webui/open-webui:cudaimage.
Access Rights and Security¶
-
Firewall: Ensure that port
443is open to allow HTTPS traffic through the Nginx proxy. -
Service Isolation: The application uses a dedicated system user for Ollama and containerized isolation for the web interface.
-
SSL/TLS: SSL certificates are managed via Certbot to secure the connection on the FQDN.
Databases¶
The application utilizes Docker volumes for data persistence rather than an external database server:
open-webui: Used by the Open WebUI container to store application data and user information.
Docker Containers and Their Deployment¶
The deployment consists of two primary containers:
Nginx Proxy Container¶
-
Image:
jonasal/nginx-certbot:latest -
Network Mode:
host -
Volumes:
-
nginx_secrets:/etc/letsencrypt(SSL certificates) -
/data/nginx/user_conf.d:/etc/nginx/user_conf.d(Configuration files) -
Environment Variables:
Open WebUI Container¶
-
Image:
ghcr.io/open-webui/open-webui:cuda -
Name:
open-webui -
Ports:
8080:8080 -
Volumes:
open-webui:/app/backend/data -
Environment Variables:
-
ENV='dev' -
OLLAMA_BASE_URLS='http://host.docker.internal:11434' -
Restart Policy:
always -
Hardware Access:
--gpus all
Custom Scripts and Additional Setup¶
The following configuration changes are applied during the setup process:
-
Ollama Service Modification: The systemd service file for Ollama is updated to include specific environment variables (
OLLAMA_HOST,OLLAMA_ORIGINS, andLLAMA_FLASH_ATTENTION) to facilitate communication with the Docker container. -
Nginx Proxy Configuration: A configuration file is generated in
/data/nginx/user_conf.d/that proxies incoming traffic from port 443 to the internal application running onhttp://127.0.0.1:8080.
Application Update Instructions¶
To update the main web interface, execute the following command in the directory containing your Docker configuration:
Location of configuration files and data¶
-
Nginx Configuration:
/data/nginx/user_conf.d/ -
Nginx Compose File:
/root/nginx/compose.yml -
Ollama Service Config:
/etc/systemd/system/ollama.service -
Open WebUI Data Volume:
open-webui(Docker managed)
Available ports for connection¶
-
HTTPS (External):
443 -
Web Interface (Internal):
8080
Starting and Stopping the application¶
Open WebUI¶
To stop the web interface:
To start the web interface:Nginx Proxy¶
To manage the proxy service (located in /root/nginx):