Mirroring Drupal

This article describe the installation of a Shibboleth protected mirror": of the current "EDIT Drupal installation for the ExpertsDatabase Web Application. The aim is to demonstrate the current state of the single sign-on integration into Drupal applications.

Both Drupal instances are running against the same MySQL database, while user authentication is handled indepently.

Installing Drupal

Drupal bases on PHP5, and we are running Drupal on a MySQL database. So, we need to install PHP5 and the MySQL module for PHP5 first.

apt-get install php5 php5-mysql

We are using Drupal 5, so we downloaded the last recent version of Drupal 5 and extract the archive to the directory /var/www

tar xvfz drupal-5.7.tar.gz -C /var/www

Configuring Drupal

Since, we want to mirror the ExpertsDB application, we start to create a subdirectory of the same name within Drupals sites directory.

mkdir -p /var/www/drupal-5.7/sites/expertsdb

Next, the configuration file settings.php from the master installation should be copied into that directory and adapted to the mirror's environment,if necessary.

In this special configuration, we introduced two modifications. First, we adapted the database access configuration within the variable db_url:

$db_url = 'mysql://drupal:secret@<ext_db_ip>/drupal5_expertdb';

Next, a special database table (+sp_expertdb+) was introduced backing up potential specific configurations beside the mirror installation on This has to be configured within the db_prefix variable.

$db_prefix = array(
      'default'   => 'expertdb_',
      'users'     => '_shared_',
      'sessions'  => '_shared_',
      'sequences' => '_shared_',
    '''  'system'    => '_sp_expertdb_' '''

Installing Drupal Modules

The mirror site should run with the same modules as the master site. So, they need to be installed on the mirror site too. Modules can be downloaded from this URL The file name of a given module and version can built along the pattern ${moduleName}-${moduleVersion}.tar.gz. For instance, the full URL to retrieve version 5.x-1.2 of the module addnode equals to

After having downloaded the required module archive, they should be extracted into the sites/all/modules directory of the Drupal installation. This is the general location to install the Drupal modules to. Modules installed there, can be used by any site configured in Drupal. Only special module requirement should be met by installing these modules into the modules subdirectory the specific site (e.g. sites/expertsdb/modules)

tar xvfz addnode-5.x-1.2.tar.gz -C /var/www/drupal-5.7/sites/all/modules

This is a list of the currently installed module versions

| Module | Version |
| | |
| addnode | 5.x-1.2 |
| admin_menu | 5.x-2.2 |
| auto_nodetitle | 5.x-1.0 |
| cck | 5.x-1.6-1 |
| cck_field_perms | 5.x-1.10 |
| computed_field | 5.x-1.2 |
| date | 5.x-1.6 |
| devel | 5.x-1.x-dev |
| fieldgroup | part of module cck |
| jstools | 5.x-0.6 |
| nodefamily | 5.x-1.3 |
| nodeprofile | 5.x-1.2 |
| subform_element | 5.x-1.3 |
| taxonomy_xml | 5.x-1.x-dev |
| token | 5.x-1.9 |
| usernode | 5.x-1.3 |
| views | 5.x-1.6 |
| views_fusion | 5.x-1.2 |

Some modules (e.g. taxon_experts) are currently implemented by EDIT developers. These modules have to be retrieved and installed directly from the following EDIT subversion respository path:

svn checkout "" "/var/www.drupal-5.7/sites/all/modules/taxon_experts"

Here is a list of modules developed by EDIT.

| Module | Version |
| taxon_experts | |
| webserver_auth-modified | |

Patching Drupal Modules

Some of the Drupal modules used within EDIT have been adapted by EDIT developers. These patches can be retrieved from the following EDIT subversion respository path: followed by the module name.

Within this directory, patch files should be named according the following pattern: ${moduleName}-${moduleVersion}.patch. So, the most recent patch for version 5.x-1.10 of module cck_field_perms should be available under this URL:

Furthermore, patches should be made avaible in a way that they are applicable within the module directory, i.e. without the need to strip of levels. If so, applying a patch to the cck_field_perms module should be easily done running this commands:

svn checkout "" "/var/www/drupal-5.7/sites/all/modules"
patch -p0 -d "/var/www/drupal-5.7/sites/all/modules/cck_field_perms" -i "$cck_field_perms-5.x-1.10.patch"

Here is a list of module patches applied.

| Module | Version |
| cck_field_perms | 5.x-1.10 |
| nodefamily | 5.x-1.3 |

Install Drupal Themes

Next, the installed Drupal themes should be identical on both sites. So, get a copy of the necessary Drupal themes and copy them into the Drupal subdirectory sites/all/themes to make them accessible for any Drupal sites.

tar xvfz themes.tgz -C /var/www/drupal-5.7/sites/all/themes

Install Drupal Files

The same applies to the Drupal files subdirectory, but you have to copy them to the Drupal subdirectory files.

tar xvfz files.tgz -C /var/www/drupal-5.7/files

Set ACLs

The Drupal installation should only be accessible by the user www-data (Apache web server). So, change the owner of Drupal files like this:

chown -R www-data:www-data /var/www/drupal-5.7

Configure Apache

For instance, it should be adequate to provide the Drupal installation as a site. To protect access to Drupal by a running Shibboleth SP installation, the following file located in /etc/apache2/sites-available/drupal should do the job

<Location /drupal-5.7>
    AuthType           shibboleth
    ShibRequireSession On
    require            valid-user

Don't forget to enable the drupal site in Apache.

a2ensite drupal

logStepStart "enable Drupal site in Apache"

Further refinements

By default, Drupal runs the site defined within the sites/default subdirectory. If you like to be more flexible regarding the selection of the default site, use symbolic links.

rm -R /var/www/drupal-5.7/sites/default
ln -s /var/www/drupal-5.7/sites/expertsdb /var/www/drupal-5.7/sites/default

The same applies, if you want more flexibility regarding the Drupal version run by default. So, use symbolic links to determine the current Drupal version, and rename the access path within /etc/apache2/sites-available/drupal from drupal-5.7 to e.g. drupal or expertsdb.

ln -s /var/www/drupal-5.7 /var/www/drupal


<Location /drupal>


Synchronising files and themes

Since, the files subdirectory also stores attachments etc, and themes may be subject of changes too, there should be a way to synchronise them automatically.

Regarding the files, using rsync to keep both sites in sync may be an appropriate solution.

Since themes are probably subject of permanent development, synchronising them by regular updates from a subversion repository, may be a good idea.

Updated by Lutz Suhrbier over 13 years ago ยท 4 revisions