This is an old revision of the document!


Multiple site (multisite)

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.

Databases

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.

Piwigo files

Download Piwigo and extract files on your web server, in /var/www/piwigo for example.

Web Server Configuration

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

Site Directories

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.

Activate Multiple Site

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.

Installations

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://yourdomain.com/piwigo or http://piwigo.yourdomain.com/.

 
Back to top
user_documentation/multiple_site.1370004620.txt.gz · Last modified: 2013/05/31 12:50 by hoedlmoser
 
 
github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact