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

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']))
{
  $site_dir = './gallery1/';
}
elseif (preg_match('#^/gallery2#', $_SERVER['SCRIPT_NAME']))
{
  $site_dir = './gallery2/';
}
 
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 full URL (if you search for a specific sub-domain).

Installations

Now you have to go to each Piwigo gallery : http://yourdomain.com/gallery1 and http://yourdomain.com/gallery2 and follow the installation each time.

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