Self-Hosting·8 min read·

Building a Self-Hosted Photo Library With Immich

Organize, search, and share your photos with Immich or Piwigo, self-hosted photo libraries with automatic backup, face recognition, and search.

NB

Netbay Engineering

Netbay Engineering

On this page

Your photo library is one of the most personal datasets you own, and handing it to a commercial cloud means trading your memories for a subscription and a terms-of-service. Self-hosted photo software has matured dramatically: Immich delivers Google Photos-style features like automatic backup, face recognition, and search, while Piwigo offers a lighter, simpler web gallery. Both run cleanly on a VPS.

The core appeal is permanence. Photos are the least reproducible data most people have, and keeping them in a format you control, on storage you pay for, means they survive account closures, subscription changes, and service shutdowns. You decide retention, resolution, and sharing policy.

This guide covers Immich as the primary recommendation, notes when Piwigo makes sense, and walks through a Compose deployment plus backup strategy.

Immich upload + ML pipeline phone backup auto upload Immich server upload dir Postgres + Redis metadata/jobs ML worker faces/search/tags ./upload volume back up this data

Immich: The Modern Default

Immich is the most ambitious open-source photo app and the closest to big-cloud behavior:

  • Automatic background backup from the mobile app.
  • Machine-learning face detection and object/scene tagging.
  • Full-text search across captions and EXIF data.
  • Albums, shared links, and a web timeline UI.

It is heavier than most self-hosted apps because the ML pipeline needs computation, so give it a bit more RAM than your average service.

Deploying Immich

Immich publishes a comprehensive Compose file. The core pieces are the server, a Postgres database, Redis, and a machine-learning worker:

yaml
services:
  server:
    image: ghcr.io/immich-app/immich-server:release
    environment:
      - DB_HOSTNAME=db
      - DB_USERNAME=postgres
      - DB_PASSWORD=secret
      - DB_DATABASE_NAME=immich
      - REDIS_HOSTNAME=redis
      - UPLOAD_LOCATION=/usr/src/app/upload
    volumes:
      - ./upload:/usr/src/app/upload
      - ./library:/usr/src/app/library
    depends_on:
      - db
      - redis
    ports:
      - "127.0.0.1:2283:2283"
    restart: unless-stopped

  ml:
    image: ghcr.io/immich-app/immich-machine-learning:release
    depends_on:
      - redis
    restart: unless-stopped

You will also need dedicated db (Postgres) and redis services; Immich's official repo includes the full file, and you can copy just the services you need.

Beware of a subtle gotcha: the ML worker can spike CPU during initial indexing of a large library. If your box is smaller, import in batches and let the face-detection jobs catch up rather than dumping ten thousand photos in one go and watching everything crawl. The design is resilient to this, it just takes time, so plan the first import for an evening when the server can work quietly.

The Upload Pipeline

Point the phone app at your server, set the backup folder, and Immich handles the rest. For bulk import from an old library, drop files straight into the upload directory:

bash
rsync -av --progress /mnt/old-photos/ ./upload/
docker exec immich-server immich-admin refresh-all

Face and object detection lag slightly behind uploads because the ML worker processes asynchronously; give it a few minutes and watch the jobs in the admin panel.

The search capability is the feature that makes a self-hosted library competitive with a commercial one. Type a person's name or an object like beach and Immich returns matching photos from across years, so you can answer the question that matters at family time: where is that photo of the beach holiday? Because the index lives on your server, none of those queries or results ever leave your infrastructure.

When to Choose Piwigo

Piwigo is a mature PHP gallery that is far lighter than Immich and great if you only need to publish an organized photo album rather than full device sync. Its plugin system covers albums, comments, and themes, and it runs on plain LAMP/PHP+MySQL. If you rarely take phone photos and mainly want a browseable wall, Piwigo is the smaller footprint choice.

There is also a practical middle path: run Immich for your full searchable archive and a lightweight Piwigo collection only for photos you explicitly choose to publish as a public gallery. That keeps the heavy ML jobs away from anything public while still giving you a curated, browseable showcase.

Takeaway

Immich brings modern photo search and automatic backup into your own infrastructure, while Piwigo covers simpler gallery needs. Whatever you choose, back up the photo volume religiously, since it is irreplaceable.

A 4 GB Ubuntu VPS with SSD storage on Netbay gives Immich comfortable room for its ML jobs — deploy in under 60 seconds at netbayhosts.in.

Keep reading

Follow along on a real VPS

Deploy Linux in under 60 seconds

These guides are written against Ubuntu, Debian, and RHEL-family images — the same ones on NetBay.

Deploy an instance