Gallery1:Mirroring Gallery - Gallery Codex
Personal tools

Gallery1:Mirroring Gallery

From Gallery Codex

Gallery includes some basic mirroring functionality, to ease the load on your master server from all the image loading.

Mirroring CANNOT be used to save disk space. It is generally only useful for load balancing.

Quick Start

Mirroring requires that you have allow_url_fopen set to On in php.ini or .htaccess. If your server does not have that directive on in php.ini, try adding this line to the bottom of your .htaccess file

php_flag allow_url_fopen on

If that doesn't work, you'll need to contact your host for further help setting it on globally

Basic steps in the mirroring process:

  • Copy your albums directory onto a remote web server.
  • Run the configuration wizard again, and add the address of the albums directory to the list of mirrors.
  • Test it!

How do I mirror my images automatically?

Gallery will not automatically update your mirror sites. However, programs such as rsync can be used with cron to automate the process. Here's a useful shell script to mirror your albums to a remote server over SSH:

#!/bin/sh
if lockfile ~/.rsync-album.lock; then
    rsync -aCz "$@" --delete -e ssh /path/to/local/albums/ remote.example.com:/path/to/remote/albums/
    rm -f ~/.rsync-album.lock
fi

Troubleshooting

Heeeelp! My images are still being loaded from the master server!

  • Are you sure you have specified the path to the remote albums directory correctly in the config wizard? Gallery will fall back to the master server if it can't find its .dat files on the remote server.
  • Did you modify the album after uploading the albums directory? Each album is pulled from the mirror on an all-or-nothing basis, so when the album is changed, it will be loaded from the master server until the mirror has been updated.

Wait a minute! Albums are being loaded from the mirrors but the highlight images are not!

This is intentional. Since Gallery only maintains state per-album, it would need to check on each album to see if its highlight image is up to date. It was decided that this would be too slow.