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.
By Simon Vasconcelos Lee
Published on 26 November 202612-minute read
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.APP_KEY once with openssl rand -base64 32 and keep it with the database password in a .env file readable by root only.mariadb-dump and an archive of the uploads. To update, change the image tag: the application container runs the migrations itself.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.
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.
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.
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:
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:
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:
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
APP_KEY is the Laravel encryption key of Lychee: it encrypts the session cookies, and anything Lychee may encrypt in its database. openssl rand -base64 32 draws 32 random bytes and writes them in base64, and the base64: prefix tells Laravel how to read them: this is the command the Lychee documentation gives, and the start script of the image refuses any key that does not decode to exactly 32 bytes. Generate it once, keep it with your backups and never change it, or Lychee can no longer read what it encrypted.DB_PASSWORD is the password of the lychee database user. openssl rand -hex 24 gives 48 hexadecimal characters, which need no quotes in .env or in YAML. Compose passes the same value to Lychee and, as MARIADB_PASSWORD, to MariaDB, which creates the user with it on its first start.MARIADB_RANDOM_ROOT_PASSWORD lets MariaDB draw one itself on its first start. Lychee never uses root, and nothing in this guide does, so there is no third secret to keep.:? in compose.yaml stops Compose with a clear message if a value is missing from .env, instead of starting with an empty one.lychee_api serves the gallery and runs the database migrations when it starts; lychee_worker, started with LYCHEE_MODE: worker, processes the uploads in the background. QUEUE_CONNECTION: database sends the jobs to the worker, and CACHE_STORE: database gives both containers the same cache, as the official file asks when a worker runs. The x-lychee block holds what they share, so the image tag is written only once.APP_URL is your public address, with https://: Lychee builds its links from it.TRUSTED_PROXIES lets Lychee believe the X-Forwarded-* headers of the reverse proxy, so it knows that visitors arrive over HTTPS and sees their real address. Requests reach the container from the gateway of its Docker network, 172.18.0.1 on our VPS, and 172.16.0.0/12 is the private range Docker takes its networks from. Lychee itself calls the wildcard * insecure: the range is narrower, and port 8106 only listens on the server itself.TIMEZONE is used for the dates of photos that carry no time zone in their EXIF data. Put yours, from the IANA list: with the default, the Diagnostics page warns that the time zone is not set.127.0.0.1: the official file publishes port 8000 on every address of the server. Published locally, Lychee is reachable only through the reverse proxy.lychee/uploads holds your photos, lychee/logs the logs of Lychee and lychee/tmp the files waiting for the worker, as in the official file. Docker creates them on the first start, and the start script gives them to the www-data user of the image.security_opt, cap_drop, cap_add, tmpfs) and the health checks come from the official file unchanged.latest. A full version, here v7.13.1, lets you choose when each update happens.On our test VPS, Lychee answered less than a minute after docker compose up -d, image download included. To check that it is ready:
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.
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:
lychee.example.com {
reverse_proxy 127.0.0.1:8106
}
systemctl reload caddy
curl -s https://lychee.example.com/ | grep -o -E '<title>[^<]*</title>'
https://, and the first visit redirected to the https:// address of the setup page, which shows that Lychee sees the requests as HTTPS.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.
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:
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.
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:
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
--force, the mariadb client stops at the first statement that fails and returns an error code. We checked it on our VPS with a broken line: the statement after it never ran, and the exit code was 1.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:
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
lychee_api ran the migration of the new version when it started, the last command printed 7.13.1, the database version moved from 071300 to 071301, and the photo uploaded on 7.13.0 was still there.edge tag follows the development branch of Lychee: stay on releases.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.
| Topic | Our teams | You |
|---|---|---|
| The server | System and security updates, server interventions included | The timing that suits you |
| Monitoring | Server monitored 24/7, with intervention without waiting for your call | Your albums, your users and your settings in Lychee |
| Lychee | Proactive monitoring: errors, slowdowns, database and disk space spotted, fix recommended | Its installation, updates and settings, which you apply, yourself or through your AI assistant |
| Photos | The disk that holds them, monitored and backed up | What you upload, share and delete |
| Backups | Every night, encrypted and kept off the machine; restores included | Lychee’s own database dumps and upload archives, and the restore request, when you need one |
| Migration | Your current server migrated, free of charge | The 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.
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 complimentary.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Simafri
Let's talk about your website
Tell us about your project in a few words: we will get back to you quickly.
Thank you! Your request has been sent. We'll get back to you shortly.
Prefer email? Write to us at support@simafri.com.