Installing PrismGram next to PhotoPrism
PrismGram (the code and the server paths still say photogram) is an Instagram-style app for your PhotoPrism library: grid, map, calendar, trips, stories, insights, share links, offline mode, and (optional) Instagram likes/views matched to your photos. A demo with generated photos is at https://prismgram.app/demo/ (no account). Your own install has no demo and no public page: logged out, it shows only the login. It never modifies PhotoPrism's software or settings (edits you make in the app are saved in PhotoPrism through its API); you log in with your PhotoPrism account.
Requirements: PhotoPrism (CE is fine) behind nginx on a Debian/Ubuntu server with systemd (root access; install.sh installs python3-pil), Python 3.10+, HTTPS on that site (the app is a PWA: offline mode and "add to home screen" need it; PhotoPrism's certificate covers /gram/); the Docker option needs Docker Compose. PhotoPrism must be served at the root of its host (https://photos.example.com/, not a sub-path like https://example.com/photos/): the app calls /api/v1/ there and install.sh adds its routes next to that site's location / {. Instagram matching and duplicates need PhotoPrism's SQLite index. With MariaDB the rest still works: the app, maps, trips, share links, and (script install) backups, which dump the database from PhotoPrism's MariaDB container when it is in the same compose project (if it isn't found, the backup leaves the database out and sends a push saying so), and photoprism-update, which then rolls back the image only.
Get the files
curl -LO https://prismgram.app/download/prismgram.tar.gz -O https://prismgram.app/download/prismgram.tar.gz.sha256
sha256sum -c prismgram.tar.gz.sha256 && tar xzf prismgram.tar.gz && cd prismgram
The checksum line verifies the download before anything is extracted. The archive holds the app, the server scripts and the install files. To update later, download it again and rerun the same install step: your settings and data are kept.
Option A: script (PhotoPrism behind nginx)
sudo bash install/install.sh # DRY_RUN=1 bash install/install.sh shows what it would do
It asks for (and detects, from the PhotoPrism container's mounts when it runs in Docker) the PhotoPrism folder, storage, originals and import folders, address and nginx site (the HTTPS server block that proxies PhotoPrism, also through a named upstream); on a rerun your earlier answers are the defaults. If it can't find that block's location / { it stops before copying anything. Then it copies the app to /var/www/photogram, scripts to /opt/photogram, writes or updates /opt/photogram/photogram.conf (keys it doesn't ask about are kept), adds include snippets/photogram.conf; to your PhotoPrism nginx site and the request limits in /etc/nginx/conf.d/photogram-limits.conf (if nginx -t then fails, every nginx file it wrote is put back or removed and nginx is not reloaded), starts photogram-api (systemd) and installs the cron jobs. The snippet also raises the proxy timeouts to 600 s for the whole site, so importing a large upload doesn't end in a 504 (unless your site sets its own); uploads need PhotoPrism's location / to allow big bodies (client_max_body_size 500M;, as in PhotoPrism's guide). Open https://<your-domain>/gram/ and log in with your PhotoPrism account (/gram/login shows the same login). Check: systemctl status photogram-api says active, https://<your-domain>/gram/api/prefs answers {"error": "log in"}, and journalctl -u photogram-api has no errors. Running the script again updates the app and keeps your settings and data.
Option B: Docker (next to PhotoPrism's docker-compose)
In PhotoPrism's folder (the one with its docker-compose.yml):
- Put the extracted folder there as
./prismgramand copy the service frominstall/docker/docker-compose.example.ymlintodocker-compose.yml. - Once, before the first start:
mkdir -p ./photogram-data && sudo chown -R 1000:1000 ./photogram-data(the container runs as uid 1000, PhotoPrism's defaultPHOTOPRISM_UID; setPHOTOGRAM_UID/PHOTOGRAM_GIDin.envand use those numbers here if your PhotoPrism uses another). docker compose up -d --build photogram.
The port is bound to localhost: open http://127.0.0.1:2343/gram/ on the server (the container passes PhotoPrism's API through, so log-in works there). On your reverse proxy route /gram/ to photogram:8790 when the proxy runs in the same compose network, or to 127.0.0.1:2343 when it is nginx on the host. Enable PhotoPrism auto-import (PHOTOPRISM_AUTO_IMPORT: "300") so Instagram pictures you choose to import are picked up. The container has no request limits or security headers of its own: keep it behind your reverse proxy (never expose port 8790 directly); install/nginx-photogram.conf and install/nginx-limits.conf show what to set there. The proxy must send X-Real-IP (the visitor's address; the API only trusts it from a proxy on the same machine or private network) and X-Forwarded-Proto https, otherwise the share-link password lock and the secure cookie cannot work. Not in the container: server backups / monitoring (ops.py) and PhotoPrism updates; use the script install for those.
Option C: your own domain
The app can live at the root of its own domain while PhotoPrism stays where it is. Run Option A first (it installs the scripts, the service and the cron jobs), then on the same server:
- Copy the app files to
/var/www/prismgram/:mkdir -p /var/www/prismgram && cp -r index.html sw.js manifest.json *.png promo fonts vendor /var/www/prismgram/(repeat this step after every update; the script only refreshes/var/www/photogram). - Copy
install/nginx-prismgram.conf.exampleto/etc/nginx/sites-available/prismgram, replace<domain>(and127.0.0.1:2342if your PhotoPrism listens somewhere else), enable it (ln -s ../sites-available/prismgram /etc/nginx/sites-enabled/),nginx -t && systemctl reload nginx, thencertbot --nginx -d <domain>for HTTPS. The file proxies only PhotoPrism's API (/api/v1/) and the PrismGram API (/api/,/s/), serves the app (also at/login), and keeps/gram/api/and/gram/s/for share links created under/gram/. It uses the request-limit zones Option A put in/etc/nginx/conf.d/photogram-limits.confand sets the security headers; once HTTPS works, uncomment theStrict-Transport-Securityline in it. - In
/opt/photogram/photogram.confsetPHOTOGRAM_SHARE_BASE=https://<domain>/sso share links use the new domain, andsystemctl restart photogram-api.
Log in at https://<domain>/.
Default map providers (any option): to choose them for users who have not picked their own, copy promo/site.json.example to promo/site.json in the app's web folder (tiles: streets, satellite, keys, mapboxStyle, same values as Settings › Maps), for example a URL-restricted Mapbox token once OpenStreetMap's fair use is exceeded. The file is public, so only use keys restricted to your domain.
Instagram (optional)
Instagram needs a Meta developer app and an Instagram professional account (Business or Creator). Once set up, a PhotoPrism admin connects their account from the app (Settings › Instagram › Connect with Instagram); a pasted token and the server script still work too. Other PhotoPrism roles may connect their own accounts if you list them in IG_ROLES (step 2).
- At https://developers.facebook.com create an app (type Business), add the Instagram product and open
API setup with Instagram business login › Business login settings. Fill in, with your own host:
- OAuth redirect URI:
https://<host>/api/instagram/callback - Deauthorize callback URL:
https://<host>/api/instagram/deauthorize - Data deletion request URL:
https://<host>/api/instagram/data-deletionThese are the Option C paths (the app at the root of its own domain). Classic installs (Option A, B) put
/gramin front of each:https://<host>/gram/api/instagram/callback,…/gram/api/instagram/deauthorize,…/gram/api/instagram/data-deletion.
- OAuth redirect URI:
- Put the app's id and secret in
/opt/photogram/photogram.conf(root-only file):
thenIG_APP_ID=<Instagram app id> IG_APP_SECRET=<Instagram app secret> IG_REDIRECT_URI=https://<host>/api/instagram/callback # classic installs: https://<host>/gram/api/instagram/callbacksystemctl restart photogram-api(Docker option: the file is./photogram-data/photogram.confand the restart isdocker compose restart photogram). Only PhotoPrism admins can connect, sync and import (IG_ROLES=admin; adduserto let every account do it); other accounts still see the Instagram features once connected by an admin. ☰ › Settings › Server (disk, backups, clean-up) is for admins whateverIG_ROLESsays. - While the app is in development mode only accounts with a role on it can connect: your own, plus anyone you add under App roles › Instagram testers (they accept the invite in Instagram › Settings › Website permissions › Tester invites). A public install needs Meta's App Review (Advanced Access).
- In PrismGram: ☰ › Settings › Instagram › Connect with Instagram. The server exchanges the code for a long-lived token,
stores it root-only, renews it nightly and runs the first sync. Permissions asked: profile and posts, insights, comments.
Alternatives: Paste a token on the same page, or
photogram-instagram-token [username]on the server.
Several users on one server
Every PhotoPrism account can log in to PrismGram (PhotoPrism share-link visitors cannot). The photo library is PhotoPrism's (shared, as in PhotoPrism CE); each user has their own data, matches, imports, trip names and share links (/var/lib/photogram/users/<uid>/, /var/lib/photogram-private/). Instagram connections are per user too, but only the roles in IG_ROLES (default: admins) may connect, sync, disconnect or import; users without a connection simply don't see the Instagram features.
Share links that survive a PhotoPrism restart (recommended)
Share links show your photos through PhotoPrism's preview token. Your own token works only while one of your PhotoPrism sessions is loaded, so after a PhotoPrism restart (an update, a reboot) or after you log out everywhere, visitors see broken photos until you open the app again. A fixed token avoids that. As root, in the PhotoPrism folder:
T=$(python3 -c "import secrets; print(secrets.token_hex(16))"), then add it to PhotoPrism's settings, e.g.echo "PHOTOPRISM_PREVIEW_TOKEN=$T" >> .env(orPHOTOPRISM_PREVIEW_TOKEN: "<the value>"underenvironment:).- The same value for PrismGram:
echo "PHOTOPRISM_PREVIEW_TOKEN=$T" >> /opt/photogram/photogram.conf(Docker option:environment: PHOTOPRISM_PREVIEW_TOKENof thephotogramservice). docker compose up -d(PhotoPrism restarts) andsystemctl restart photogram-api.
Keep the value secret like a password: it opens any photo's thumbnail. It never leaves the server (the share proxy uses it).
Push notifications, backups and PhotoPrism updates (script install, PhotoPrism in Docker)
When PhotoPrism runs in Docker on the same server, the script also installs /etc/cron.d/photogram-ops and photoprism-update. Edit /opt/photogram/ops.conf (root-only): NTFY_TOPIC (subscribe to it in the ntfy app), REMOTE for off-server copies via rclone (Google Drive, S3, DigitalOcean Spaces — it must be an rclone crypt remote: the archive holds PhotoPrism's database and your tokens, and the backup refuses to upload to anything else; copies older than 200 days are removed there). In the app, ☰ › Settings › Server (admins) shows disk, folder sizes, memory, backups and jobs, and can run a backup, PhotoPrism's cleanup, a size measurement or an update check. Daily backup 03:30 (PhotoPrism's compose folder, index, settings and the PrismGram data, kept in <PhotoPrism folder>/backup/photogram/: 7 daily, 4 weekly, 6 monthly), hourly checks (disk, PhotoPrism up, Instagram sync fresh), weekly summary, weekly photoprism cleanup, a daily check for a newer PhotoPrism image (same tag as the one the container runs). photoprism-update updates PhotoPrism safely: backup + index snapshot, pull, restart, health check, automatic rollback if the new version does not start. Paths come from photogram.conf (PHOTOPRISM_STORAGE, PHOTOPRISM_ORIGINALS: originals elsewhere are still copied to REMOTE).
MariaDB. When PhotoPrism uses MariaDB (PHOTOPRISM_DATABASE_DRIVER: mysql), the backup runs mariadb-dump inside the database container of the same compose project (the service named in PHOTOPRISM_DATABASE_SERVER, with PhotoPrism's own database user and password) and stores it as <storage>/photoprism-mariadb.sql in the archive. If that container isn't found (database on another host), the archive leaves the database out, the log says so and a push "database not included (MariaDB)" is sent once a week: back that database up yourself. photoprism-update then has no database snapshot and rolls back the image only.
Keep the rclone passwords off the server. The crypt remote's passwords exist only in /root/.config/rclone/rclone.conf on the server. Copy that file (or the two passwords) into your password manager now: if the server is lost, the off-server archives and originals cannot be decrypted without them.
Restore
Each archive (photogram-YYYY-MM-DD.tar.gz) holds a snapshot of PhotoPrism's index, PhotoPrism's .env, docker-compose.yml, config, sidecar, users and serial files, the nginx site, snippet and limits files, the photogram-api service file, the cron files, /opt/photogram (settings, ops.conf, Instagram tokens), /var/lib/photogram* and the web folders. Paths are stored without the leading /. Originals are not in it (they are on the off-server remote when REMOTE is set); thumbnails are rebuilt. With MariaDB the archive has <storage>/photoprism-mariadb.sql instead of index.db (step 7).
- New server: install PhotoPrism (Docker, same folder as before, same version or newer) and PrismGram (Option A above).
- Get the archive and the originals. From the old disk:
<PhotoPrism folder>/backup/photogram/. From the remote: restore yourrclone.conf(password manager) to/root/.config/rclone/, thenrclone copy <remote>/archives/photogram-YYYY-MM-DD.tar.gz /root/andrclone copy <remote>/originals <PhotoPrism folder>/originals. - Stop everything:
cd <PhotoPrism folder> && docker compose down,systemctl stop photogram-api. - Remove the new, empty index's journal so it is not replayed over the restored one:
rm -f <PhotoPrism folder>/storage/index.db-wal <PhotoPrism folder>/storage/index.db-shm. - Extract:
tar -xzpf /root/photogram-YYYY-MM-DD.tar.gz -C /(it overwrites what the installer wrote with your old files). If the PhotoPrism folder is different on the new server, extract into an empty folder and copy the parts by hand. - Run
sudo bash install/install.shagain: it keeps the restored settings and data and puts back the current scripts, nginx include, service and cron jobs. It keeps the PhotoPrism container name from the restored settings while PhotoPrism is stopped; if PhotoPrism now runs from a different folder (another container name), run it once more after step 7 and answer the folder questions with the new paths (the suggested answers are the restored, old ones). - Start:
docker compose up -d(in the PhotoPrism folder),systemctl daemon-reload && systemctl restart photogram-api,nginx -t && systemctl reload nginx. MariaDB: start only the database first (docker compose up -d mariadb), load the dump:docker compose exec -T mariadb sh -c 'mariadb -u root -p"$MARIADB_ROOT_PASSWORD" photoprism' < <storage>/photoprism-mariadb.sql(use your service and database names), thendocker compose up -d. - Rebuild the thumbnails:
docker exec <container> photoprism thumbs -f(takes a while on a large library). - Check: log in to PhotoPrism and the app, then Settings › Server › run a backup.
Remove
Script install (Option A, and C if you used it), as root, in this order (nginx keeps working at every step):
- Service and jobs:
systemctl disable --now photogram-api, thenrm /etc/systemd/system/photogram-api.service /etc/cron.d/photogram-instagram /etc/cron.d/photogram-ops /usr/local/bin/photogram-instagram-token /usr/local/bin/photoprism-updateandsystemctl daemon-reload. - nginx, the users of the request-limit zones first: Option C's site
rm /etc/nginx/sites-enabled/prismgram /etc/nginx/sites-available/prismgram; delete theinclude snippets/photogram.conf;line from your PhotoPrism site, thenrm /etc/nginx/snippets/photogram.conf /etc/nginx/conf.d/photogram-limits.conf;nginx -t && systemctl reload nginx(ifnginx -tcomplains, something still uses a removed file: fix that before reloading). - Files:
rm -r /var/www/photogram /var/www/prismgram /opt/photogram /var/lib/photogram /var/lib/photogram-private /var/lib/photogram-ops,rm /var/log/photogram-.log /root/nginx-site.before-photogram.(the installer's copies of your nginx site from before PrismGram). - Backups:
<PhotoPrism folder>/backup/photogram/*.tar.gzhold PhotoPrism's database, the Instagram tokens andIG_APP_SECRET. Delete them (rm -r <PhotoPrism folder>/backup/photogram), or keep them knowingly and root-only; the same goes for the copies on yourREMOTE.
Docker (Option B): in PhotoPrism's folder docker compose rm -sf photogram, delete the photogram service from docker-compose.yml, remove its /gram/ route from your reverse proxy, then rm -r ./photogram-data ./prismgram (photogram-data holds the tokens and IG_APP_SECRET) and docker image prune for the built image.
PhotoPrism itself is untouched; Instagram pictures imported into it stay there.
Files
| Path | What |
|---|---|
/opt/photogram/photogram.conf | where PhotoPrism lives (folder, storage, originals, import), the nginx site, owner, share-link base, Instagram app id / secret / redirect URI / allowed roles IG_ROLES (root-only) |
/opt/photogram/ | scripts, caches, owner token instagram.env, other users in accounts/<uid>/ |
/var/lib/photogram/ | data the app reads (owner) and users/<uid>/ (other users) |
/var/lib/photogram-private/ | share links, per-user preferences (never served directly) |
/etc/nginx/snippets/photogram.conf | the nginx routes |
/etc/nginx/conf.d/photogram-limits.conf | request limits per client address (used by the routes above and the own-domain example) |
/etc/systemd/system/photogram-api.service | the API service (sandboxed: writes only its own folders, /var/log, the Docker socket and PhotoPrism's backup folder; journalctl -u photogram-api for its log) |
/etc/cron.d/photogram-instagram, /etc/cron.d/photogram-ops | nightly Instagram sync + duplicates, 10-minute import check; backups / checks / summary (Docker installs) |
/usr/local/bin/photogram-instagram-token, /usr/local/bin/photoprism-update | paste an Instagram token on the server; update PhotoPrism with backup and rollback |
/var/log/photogram-instagram.log, /var/log/photogram-ops.log | logs of the cron jobs |
/root/nginx-site.before-photogram.* | copy of your PhotoPrism nginx site from before the installer added the include |
/var/lib/photogram-ops/, <PhotoPrism folder>/backup/photogram/ | state of the checks; the backup archives |