How to Install PhotoPrism on AlmaLinux 9
PhotoPrism is an AI-powered application that allows you to host, organize, and share your photo collection independently. Because its AI indexing requires solid processing power and read/write speeds, deploying it on a robust virtual private server ensures a smooth experience. Below is the complete step-by-step guide to installing PhotoPrism using Docker and securing it with an Nginx reverse proxy on AlmaLinux 9.
Prerequisites
-
A server running AlmaLinux 9.
-
Root access to the server.
-
A domain or subdomain pointed to your server’s IP address (e.g., photos.example.com).
Step 1: Connect to the Server via SSH
From your local machine, log in to your server as the root user:
ssh root@YOUR_SERVER_IP
Step 2: Update the System
Ensure all installed packages are updated to their latest versions:
dnf update -y
Step 3: Install Required System Packages
These dependencies are required to securely add external repositories and download Docker components:
dnf install ca-certificates curl gnupg2 dnf-utils -y
Step 4: Add the Docker Repository
Add the official Docker repository that is compatible with AlmaLinux 9:
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Step 5: Refresh the Package Cache
Load the metadata from the newly added Docker repository:
dnf makecache
Step 6: Install Docker and Docker Compose
Install the Docker Engine and the Docker Compose v2 plugin:
dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
Step 7: Enable and Start Docker
Start the Docker service and configure it to launch automatically at boot:
systemctl enable docker systemctl start docker
Step 8: Verify the Docker Installation
Confirm that both Docker and Docker Compose are installed correctly:
docker --version docker compose version
Step 9: Create the PhotoPrism Directory
This directory will house your PhotoPrism configuration and data:
mkdir -p /opt/photoprism cd /opt/photoprism
Step 10: Download the Docker Compose Template
Fetch the official PhotoPrism Docker Compose configuration file:
wget https://dl.photoprism.app/docker/compose.yaml -O docker-compose.yml
Step 11: Edit the Docker Compose Configuration
Open the file to configure your environment variables:
nano docker-compose.yml
Adjust the file to match the following configuration. This sets up your admin password and maps the container directories to your VPS storage:
services:
photoprism:
image: photoprism/photoprism:latest
restart: unless-stopped
ports:
- "2342:2342"
environment:
PHOTOPRISM_ADMIN_PASSWORD: "StrongAdminPasswordHere"
PHOTOPRISM_ORIGINALS_PATH: "/photoprism/originals"
PHOTOPRISM_STORAGE_PATH: "/photoprism/storage"
volumes:
- /opt/photoprism/originals:/photoprism/originals
- /opt/photoprism/storage:/photoprism/storage
Save and exit the file (Press CTRL+X, then Y, then Enter).
Step 12: Create Required Data Directories
Create the specific folders mapped in the YAML file to ensure your photos and AI metadata persist across container restarts:
mkdir -p /opt/photoprism/originals mkdir -p /opt/photoprism/storage
Step 13: Pull the PhotoPrism Image
Download the latest PhotoPrism Docker image from the repository:
docker compose pull
Step 14: Start PhotoPrism
Launch the container in the background (detached mode):
docker compose up -d
Step 15: Verify Running Containers
Confirm that the PhotoPrism container is up and running:
docker compose ps
Step 16: Install Nginx
Install Nginx, which will act as a reverse proxy to handle external web traffic:
dnf install nginx -y
Step 17: Enable and Start Nginx
Start the web server and enable it on boot:
systemctl enable nginx systemctl start nginx systemctl status nginx
Step 18: Create the Nginx Configuration
Create a new configuration block for your PhotoPrism domain:
nano /etc/nginx/conf.d/photoprism.conf
Paste the following configuration. This setup allows large photo uploads and supports WebSocket connections:
server {
listen 80;
server_name _;
client_max_body_size 500M;
location / {
proxy_pass http://127.0.0.1:2342;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_buffering off;
}
}
Save and exit the file.
Step 19: Test and Reload Nginx
Verify that your Nginx syntax is correct, then reload the service to apply the changes:
nginx -t systemctl reload nginx
Conclusion
Your private photo cloud is now live. Open your web browser and navigate to your domain ([http://your_IP_server). You can log in using the admin username and the strong password you configured in Step 11.
Note: PhotoPrism performs best on fast storage and reliable CPU resources, especially during the initial AI indexing of large photo libraries. Utilizing an NVMe VPS or a high-performance Storage VPS will drastically reduce processing times when uploading new albums.