Self-host Lychee on a managed VPS: your own photo gallery

To self-host Lychee on a managed VPS is to keep your photos, albums and sharing links on a server of your own, which our teams keep up to date and monitor day and night. Lychee is a free, open source photo management system under the MIT license: you upload, organize and share your pictures from the browser. This guide follows its official Docker Compose file at version 7.13.1, and we ran every command on a Simafri VPS before writing it: installation with MariaDB and a queue worker, HTTPS, the first account, backups, a restore and an upgrade.

Simon Vasconcelos Lee By Published on 26 November 202612 minute read

All guides

In short

  1. The MIT license lets you run Lychee for yourself, your family, your club or your clients with no license to buy; the Supporter Edition adds extra features for sponsors.
  2. Install it with Docker Compose: the official image ghcr.io/lycheeorg/lychee, a queue worker from the same image and MariaDB 11.8, with port 8106 published on 127.0.0.1 behind an HTTPS reverse proxy.
  3. Generate APP_KEY once with openssl rand -base64 32 and keep it with the database password in a .env file readable by root only.
  4. Create the administrator on the setup page that Lychee shows at its first visit, right after HTTPS is in place.
  5. Back up with mariadb-dump and an archive of the uploads. To update, change the image tag: the application container runs the migrations itself.

What Lychee does

Lychee is a photo management system written in PHP on Laravel, maintained by LycheeOrg. It runs in the browser like an application: you drop photos into it, sort them into albums and share them, while the files stay on your server.

What the MIT license allows

Lychee is published under the MIT license. You can use it free of charge, for yourself, your organization or your clients, copy it, modify it and redistribute it, provided you keep the copyright notice and the license text. The software is provided without warranty.

The Supporter Edition is a thank-you to the sponsors of the project: a license key, entered in the About dialog, unlocks features such as statistics, user groups, watermarking and an upload quota per user. Its code is published under the same MIT license. Nothing in this guide needs it.

The resources to plan for

Here is what we measured on our test VPS, with 2 vCPU and 4 GB of memory, after the installation and a first photo:

Server size therefore depends mostly on the size of your library and on how many photos you upload at once. On a managed VPS, tell us about your usage and we will recommend the right size.

Installing with Docker Compose

The official image, ghcr.io/lycheeorg/lychee, contains Lychee, PHP and FrankenPHP. On a server with Docker Engine and its Compose plugin, installed from Docker’s repository for Ubuntu, create a folder for Lychee and work in it:

Terminal
mkdir -p /opt/lychee

In /opt/lychee, put this compose.yaml, based on the official docker-compose.yaml of Lychee and kept to what this installation uses:

compose.yaml
x-lychee: &lychee
  image: ghcr.io/lycheeorg/lychee:v7.13.1
  restart: unless-stopped
  security_opt:
    - no-new-privileges:true
    - seccomp:unconfined
  cap_drop:
    - ALL
  cap_add:
    - CHOWN
    - SETGID
    - SETUID
    - DAC_OVERRIDE
    - NET_BIND_SERVICE
  tmpfs:
    - /tmp:noexec,nosuid,nodev,size=100m
  environment: &lychee-env
    APP_KEY: ${APP_KEY:?set APP_KEY in .env}
    APP_URL: https://lychee.example.com
    TIMEZONE: Europe/Paris
    TRUSTED_PROXIES: 172.16.0.0/12
    DB_CONNECTION: mysql
    DB_HOST: lychee_db
    DB_PORT: 3306
    DB_DATABASE: lychee
    DB_USERNAME: lychee
    DB_PASSWORD: ${DB_PASSWORD:?set DB_PASSWORD in .env}
    QUEUE_CONNECTION: database
    CACHE_STORE: database
  volumes:
    - ./lychee/uploads:/app/public/uploads
    - ./lychee/logs:/app/storage/logs
    - ./lychee/tmp:/app/storage/tmp

services:
  lychee_api:
    <<: *lychee
    ports:
      - "127.0.0.1:8106:8000"
    depends_on:
      lychee_db:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/up"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s

  lychee_worker:
    <<: *lychee
    environment:
      <<: *lychee-env
      LYCHEE_MODE: worker
    depends_on:
      lychee_db:
        condition: service_healthy
      lychee_api:
        condition: service_healthy
    healthcheck:
      test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s

  lychee_db:
    image: mariadb:11.8
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    cap_drop:
      - ALL
    cap_add:
      - SETGID
      - SETUID
      - DAC_OVERRIDE
      - CHOWN
    tmpfs:
      - /tmp:noexec,nosuid,nodev,size=200m
      - /var/run/mysqld:noexec,nosuid,nodev,size=10m
    environment:
      MARIADB_DATABASE: lychee
      MARIADB_USER: lychee
      MARIADB_PASSWORD: ${DB_PASSWORD:?set DB_PASSWORD in .env}
      MARIADB_RANDOM_ROOT_PASSWORD: "1"
    volumes:
      - mariadb_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 5s
      timeout: 3s
      retries: 10
      start_period: 10s

volumes:
  mariadb_data:

The two secrets go in a .env file next to it, which Docker Compose reads on its own. Create it readable by root only, then start the stack:

Terminal, in /opt/lychee
umask 077
printf 'APP_KEY=base64:%s\nDB_PASSWORD=%s\n' "$(openssl rand -base64 32)" "$(openssl rand -hex 24)" > .env
umask 022
docker compose up -d

The secrets, and how they are made

The other settings

On our test VPS, Lychee answered less than a minute after docker compose up -d, image download included. To check that it is ready:

Terminal, in /opt/lychee
until curl -sf http://127.0.0.1:8106/up >/dev/null; do sleep 5; done
docker compose ps
docker compose logs lychee_api | grep -E 'migrat|Migrat|ready|ERROR' | tail -8

The three services show healthy, and the log of lychee_api ends with “Application ready!” after the migrations.

HTTPS: the reverse proxy

The container serves Lychee over HTTP, on port 8106 of the server. HTTPS is handled by a reverse proxy in front of it, which must forward the public Host header and X-Forwarded-Proto. We tested Caddy, installed from its official Debian and Ubuntu repository: it obtains the Let’s Encrypt certificate itself, renews it, and forwards these headers by default. Add this block to the Caddyfile, then reload Caddy:

/etc/caddy/Caddyfile
lychee.example.com {
	reverse_proxy 127.0.0.1:8106
}
Terminal
systemctl reload caddy
curl -s https://lychee.example.com/ | grep -o -E '<title>[^<]*</title>'

The first account

As long as no administrator exists, Lychee sends every visitor to its setup page, /install/admin. Open your address right after reloading Caddy, so that you are the first one there: choose a username and a long password, from your password manager, and confirm it. This is the path the Lychee documentation describes, and it also records you as the owner of the gallery. Once the account exists, the setup page answers 403 and the address shows the gallery.

Lychee also has a command, lychee:create_user, which creates a user from the terminal. We tried it first for the administrator: the account worked, but the Diagnostics page then reported “Wrong property for owner_id”, since only the setup page records the owner. Use the setup page for the first account.

Sign in, then open the upload button at the top of the gallery and add a few photos. On our test VPS, a JPEG photo uploaded through the same API the interface uses was handed to the worker, which generated its smaller versions, thumbnails included, in about 150 ms; its original kept the same SHA-256 checksum as the file we sent. A wrong password was refused with a 401.

Users, sharing and settings

Backups

Everything lives in three places: the MariaDB database, with your albums, users and the description of each photo; the lychee/uploads folder, with the photo files; and your .env file. Keep the latter safe: APP_KEY is needed to read what Lychee encrypts. The MariaDB image includes mariadb-dump, and the uploads are a folder of the server:

Terminal, in /opt/lychee
umask 077
docker compose exec -T lychee_db sh -c 'exec mariadb-dump --single-transaction -u lychee -p"$MARIADB_PASSWORD" lychee' > lychee-$(date +%F).sql
tar -czf uploads-$(date +%F).tar.gz lychee/uploads
cp .env env-$(date +%F).bak
umask 022

The dump reads the database password inside the container, so it never appears on the command line, and umask 077 leaves the three files readable by root only. Schedule this copy and send it off the server. Stored on the disk, the files are also included in the server’s nightly backups.

Restoring

On the same installation, or on a new one with the same compose.yaml and .env, stop Lychee, drop and recreate the database, load the dump, put the uploads back, then start it again:

Terminal, in /opt/lychee
docker compose stop lychee_api lychee_worker
docker compose exec -T lychee_db sh -c 'exec mariadb -u lychee -p"$MARIADB_PASSWORD" -e "DROP DATABASE lychee; CREATE DATABASE lychee CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"'
docker compose exec -T lychee_db sh -c 'exec mariadb -u lychee -p"$MARIADB_PASSWORD" lychee' < lychee-2026-11-20.sql
rm -rf lychee/uploads
tar -xzf uploads-2026-11-20.tar.gz
docker compose up -d

Updates

Lychee publishes a release every week or two, and each one gets an image tag on the GitHub Container Registry, v followed by the version. This guide pins 7.13.1, the latest release when we tested it: check the releases page for a newer one before you install. Take a backup, change the image tag in the x-lychee block of compose.yaml, then pull the new image and recreate the containers:

Terminal, in /opt/lychee
docker compose pull
docker compose up -d
docker compose logs lychee_api --since 3m | grep -E "Running database migrations|Running migrations|bump_version|Nothing to migrate|Application ready"
docker compose exec -T lychee_api cat version.md

Who does what on a managed VPS

Self-hosting means running the server on top of the application. On a managed VPS, our teams take charge of the server and proactively monitor your instance; Lychee remains your software, with your photos and your settings.

TopicOur teamsYou
The serverSystem and security updates, server interventions includedThe timing that suits you
MonitoringServer monitored 24/7, with intervention without waiting for your callYour albums, your users and your settings in Lychee
LycheeProactive monitoring: errors, slowdowns, database and disk space spotted, fix recommendedIts installation, updates and settings, which you apply, yourself or through your AI assistant
PhotosThe disk that holds them, monitored and backed upWhat you upload, share and delete
BackupsEvery night, encrypted and kept off the machine; restores includedLychee’s own database dumps and upload archives, and the restore request, when you need one
MigrationYour current server migrated, free of chargeThe timing of the switch

If you would rather have our teams work inside the application itself, that service is billed by the hour or at a fixed rate, with an estimate shared before the work starts.

Lychee, on a server run for you

With a Simafri Managed VPS, our teams keep your Lychee instance’s server up to date, monitor it day and night and step in without waiting for your call; they also proactively monitor your instance and recommend useful fixes, which you apply, yourself or through your AI assistant. Backups are encrypted every night and kept off the machine, restores are included, and migrating your current server is free.

Explore Managed VPS

Frequently asked questions

Is Lychee free?

Yes. Lychee is under the MIT license: you can run it for yourself, your organization or your clients with no license to buy. The Supporter Edition adds features such as statistics, user groups and watermarking for the sponsors of the project, under the same license. What remains is the cost of the server that runs it.

How do I install Lychee with Docker Compose?

Use the ghcr.io/lycheeorg/lychee image for two services, the application and a queue worker with LYCHEE_MODE set to worker, and MariaDB 11.8 for the database. Put APP_KEY and the database password in a .env file, set APP_URL to your https address and TRUSTED_PROXIES to the Docker range, publish port 8106 on 127.0.0.1, run docker compose up -d, and put an HTTPS reverse proxy in front.

How do I generate the Lychee APP_KEY?

Run openssl rand -base64 32 and put the result after base64: in APP_KEY, as the Lychee documentation says. The image refuses a key that does not decode to exactly 32 bytes. Generate it once and keep it: Lychee uses it to encrypt sessions and data, and a new key cannot read what the old one encrypted.

Should Lychee use SQLite or MariaDB?

MariaDB or PostgreSQL for a server. SQLite locks the whole database file on each write, which becomes a problem as soon as a queue worker and web requests write at the same time. The official Docker Compose file uses MariaDB.

How do I create the first Lychee admin account?

Open your address once Lychee is running: as long as no administrator exists, it sends you to /install/admin, where you choose a username and a password. Do it right after setting up HTTPS. That page also records you as the owner of the gallery, which the lychee:create_user command does not do.

How much memory does Lychee need?

Little at rest. On our test VPS, the application used about 230 to 260 MB, the queue worker about 60 MB and MariaDB about 140 to 160 MB, and the images take about 1.2 GB of disk. Processing large uploads takes more, in the worker.

How do I back up Lychee in Docker?

Dump the database with mariadb-dump from the MariaDB container, archive the lychee/uploads folder, and keep a copy of your .env file. To restore, stop Lychee, drop and recreate the database, load the dump with mariadb, extract the archive, then start Lychee again.

How do I update Lychee in Docker?

Take a backup, change the image tag in compose.yaml, then run docker compose pull and docker compose up -d. The application container runs the database migrations when it starts, and the worker waits for them before processing jobs.

Does a managed VPS cover Lychee?

A managed VPS covers the server: system, security, monitoring and backups. Our teams also proactively monitor your instance and recommend useful fixes, which you apply. Work inside the application is billed by the hour or at a fixed rate.

Contact us