This is an old revision of the document!
The Multiple site feature, introduced in Piwigo 2.2, is the ability to have several galleries with a single Piwigo installed. This feature is used on Piwigo.com where thousands of galleries run on one Piwigo installation.
Only the files are shared, each gallery has a specific database or a set of tables in the same database if you use a specific table prefix for each gallery.
Download Piwigo and extract files on your web server, in /var/www/piwigo for example.
In your Apache configuration file, you need something like:
Alias /gallery1 /var/www/piwigo Alias /gallery2 /var/www/piwigo
Or if you like to do it on Server Name then just add a ServerAlias in your VirtualHost config:
ServerName piwigo.yourdomain.com ServerAlias gallery1.yourdomain.com ServerAlias gallery2.yourdomain.com
Create directories /var/www/piwigo/gallery1 and /var/www/piwigo/gallery2 and sub-drectories, with write access for www-data (chmod 0777 if you don't understand what www-data is)
mkdir /var/www/piwigo/gallery1 cd /var/www/piwigo/gallery1 mkdir -p local/config _data upload chown -R www-data:www-data .
Let's do the same for gallery2:
mkdir /var/www/piwigo/gallery2 cd /var/www/piwigo/gallery2 mkdir -p local/config _data upload chown -R www-data:www-data .
and so on for other sites.
In your local/config/config.inc.php, you need this kind of code:
if (preg_match('#^/gallery1#', $_SERVER['SCRIPT_NAME'])) #if (preg_match('/^gallery1.yourdomain.com$/', $_SERVER['SERVER_NAME'])) { $site_dir = 'gallery1'; } elseif (preg_match('#^/gallery2#', $_SERVER['SCRIPT_NAME'])) #elseif (preg_match('/^gallery2.yourdomain.com$/', $_SERVER['SERVER_NAME'])) { $site_dir = 'gallery2'; } if (isset($site_dir)) { define('PWG_LOCAL_DIR', $site_dir.'/local/'); $conf['upload_dir'] = './'.$site_dir.'/upload'; $conf['data_location'] = $site_dir.'/_data/'; # in case there is a specific configuration file for each "site" @include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php'); }
The trick is to find how Piwigo can understand if it's currently running gallery1 or gallery2. In this example, we have used the $_SERVER['SCRIPT_NAME'] variable. You can also use an environment variable set by your webserver or the servers name in the $_SERVER['SERVER_NAME'] variable (if you search for a specific sub-domain). If no Alias or Server Name matches it will just use the default, root gallery.
Now you have to go to each Piwigo gallery: http://yourdomain.com/gallery1 and http://yourdomain.com/gallery2 or http://gallery1.yourdomain.com/ and http://gallery2.yourdomain.com/ (if you match on Server Name) and follow the installation each time. keep in mind that the default, root gallery should be available somewhere at http://yourdoamin.com/piwigo or http://piwigo.yourdomain.com/.