Difference between revisions of "Integration:Drupal:Installation" - Gallery Codex
Personal tools

Difference between revisions of "Integration:Drupal:Installation"

From Gallery Codex

Line 1: Line 1:
<h1>NOTE: This documentation is for the g2bridge module for Drupal 4, 5 or 6.<br><br>For Drupal 7+, please refer to the [http://codex.gallery2.org/Gallery2:Modules:g2drupal G2Drupal Bridge]</h1>
<div style="margin: 10px; padding: 5px 10px; border:2px solid #f00;">
NOTE: This documentation is for the g2bridge module for Drupal 4, 5 or 6.<br>For Drupal 7+, please refer to the [http://codex.gallery2.org/Gallery2:Modules:g2drupal G2Drupal Bridge]
== Gallery 2  ==
== Gallery 2  ==

Revision as of 10:49, 30 September 2012

NOTE: This documentation is for the g2bridge module for Drupal 4, 5 or 6.
For Drupal 7+, please refer to the G2Drupal Bridge

Gallery 2

[Download] Gallery2 and install it according to documentation. Make sure to get the 'full' package because 'minimal' and 'typical' do not contain the required 'ImageBlock' (and 'ImageFrame') plugins. Gallery2 should be installed *inside* (or below) your Drupal root directory so that it's accessible by the same website. If you want/need to install Gallery2 somewhere else (e.g. at the same level as your Drupal codebase), you should create a symlink to G2 from inside your Drupal folder, e.g.

cd /var/www/drupaldir
ln -s /path/to/gallery2

Warning - Do not place your Gallery2 codebase at "/drupaldir/gallery". We usually recommend that you place G2 (or the symlink) in "/drupaldir/gallery2", but you can place it anywhere you like except in "/drupaldir/gallery" because this conflicts with the Drupal gallery module path as Drupal assumes that http://www.drupalsite.com/gallery refers to the Drupal module (and not to the G2 codebase).

FYI: In principle you can even place G2 outside the Drupal root directory and it should still work. The reason why we highly recommend you to keep G2 inside the Drupal dir is a limitation of the Drupal API and some advanced features that require this configuration. The drupal_add_js/css() functions do not support external paths. But without these functions we cant preserve a certain order of js/css includes in the resulting page. This is important for certain purposes, i.e. lightbox integration, jquery usage, ...

If you want/need a Gallery2 multisite setup, we recommend that you place the individual sites at "/drupaldir/sites/yoursite/gallery2".

Make sure you have the "Image Block" plugin (Gallery2:Modules:imageblock) installed and enabled in G2 before proceeding with the embedded setup. You should also configure "URL Rewrite" in your standalone Gallery2 and set the "Rules" to

Show Item: "gallery/v/%path%"

Please read the URL Rewrite tutorial for more information. http://codex.gallery2.org/Integration:Drupal:Quick_Start

If you plan to create a multilingual site (e.g. using the i18n module in Drupal), do NOT prefix the paths with "%language%".


Log out of your standalone Gallery2 to avoid session issues during embedded setup.

Get the latest gallery module package from drupal.org ([1]). Unpack the archive into your "/modules" (or "/sites/all/modules" or "/sites/yoursite/modules") directory. Unless explicitly stated the most recent version of gallery module for your Drupal core release always works with the latest version of Gallery2.

Enable the gallery module (and optionally the other modules from the package) at Administer > Site building > Modules (admin/build/modules). To setup the embedded gallery you still need to specify some details of your G2 installation. Start the installation wizard provided by the gallery module by navigating to Administer > Site configuration > Gallery settings (admin/settings/gallery). You can always return to the "Install" tab (admin/settings/gallery/install) later to get a configuration and status report of your embedded G2 and its plugins.

The install wizard should be quite intuitive to walk through. Please read the help text provided for the individual steps carefully as it already contains all instructions you need to know.

Step 1: PHP Memory Test

Usually there is nothing to do in this step. It's just to ensure that a minimum of 24 MB of php memory is available on your server. Depending on your actual configuration (mainly the number of Drupal modules and G2 plugins enabled) you might even need more memory to run Gallery2 embedded.

Step 2: Gallery2 location settings

The Gallery2 location is the most wanted piece of information required to successfully embed G2 in Drupal. For most users the "Auto Configuration" should work, but for certain host configurations you might require to switch to "Manual Configuration" to complete this step.

Lets assume the following directory layout for single-site G2

WebPath to Drupal:       "/drupal5/"
ServerPath to Drupal:    "/var/www/drupal5/"
ServerPath to Gallery2:  "/var/www/drupal5/gallery2/"

and especially for multi-site

ServerPath to Gallery2: "/var/www/drupal5/sites/yoursite/gallery2/"
(ServerPath to Gallery codebase = ServerPath of single-site G2)

If your domain points directly to your Drupal install, you may omit "/drupal5/" in the sample URLs (but not in the filesystem paths). All examples in the next section refer to the above configuration.

Auto Configuration

By default the install wizard tries to derive the filesystem path from the "Gallery2 URL or URI" you enter here. For example:

single-site: "/drupal5/gallery2/"
multi-site:  "/drupal5/sites/yoursite/gallery2/"

(or the respective full URLs to Gallery2, e.g. http://www.example.com/drupal5/gallery2/ or http://www.example.com/gallery2/ if your domain points directly to Drupal)

In case you are confident that your path is correct and the module still fails to detect Gallery2, make sure the G2 folder is not protected by your server management system (i.e. cPanel, Plesk, VHCS2, ...). If for some reason auto-detection fails completely, simply switch to "Manual Configuration" instead.

Manual Configuration

The "Manual Configuration" mode lets you enter all values manually (and does not rely on the auto-detect mechanism). The "Gallery2 URL or URI" value should be the same as above, "Gallery2 filesystem path" refers to the absolute location of G2 in your server's filesystem (including the base path to your webroot).


Gallery2 URL or URI:       "/drupal5/gallery2/"
Gallery2 filesystem path:  "/var/www/drupal5/gallery2/"
Embed URI:                 "/drupal5/index.php?q=gallery"

or multi-site:

Gallery2 URL or URI:       "/drupal5/sites/yoursite/gallery2/"
Gallery2 filesystem path:  "/var/www/drupal5/sites/yoursite/gallery2/"
Embed URI:                 "/drupal5/index.php?q=gallery"

If you plan to use the i18n module for multilingual sites, make sure the language prefix is NOT included in the "Embed URI" value.

Step 3: Drupal Modules / Gallery2 Plugins

Some Gallery2 plugins are required for embedded operation and some are better uninstalled to avoid conflicts with Drupal. This step is to notify you of these recommended/missing or unneeded Gallery2 plugins and optional Drupal modules you can install to extend functionality.

Step 4: Clean URL / URL Rewrite

This step requires the "URL Rewrite" plugin enabled and configured in standalone Gallery2. Usually the wizard is able to auto-detect the path to the .htaccess file of your Drupal installation. Otherwise you have to specify it here. Thats needed because G2 will add its own rewrite rules to resolve short urls in Drupal. You may also decide to skip this step in case you dont want/need short URLs for your embedded gallery.

Please read the URL Rewrite tutorial for more information.

Step 5: Initial User Synchronization

It is essential for the embedded Gallery to work correctly that your Drupal users/groups are sync correctly with their Gallery2 counterparts. Missing user/group mappings will cause severe issues in embedded operation. For that reason it is highly recommended that you synchronize all users/groups during installation.

However if you have a large number of users in Gallery2 already and you want to import them into Drupal, you might skip this step and use the "Advanced Sync" (admin/user/gallery/advanced) options instead.

Post-Install tasks

At this point your gallery is ready for embedded operation. You may now continue with the customization of your embedded gallery by configuring various options of gallery module (see Configuration).

Most users want to enable at least the "Gallery Navigation" block and/or the "Gallery Image/Grid" block. You can do so in the Drupal "Blocks" administration at Administer > Site building > Blocks (admin/build/block).

Access control

Also make sure that you grant your users access to the embedded gallery. Browse to Administer > User management > Access control and configure permissions for

  • access gallery
  • access standalone g2image
  • administer gallery settings

Thanks for reading this tutorial. We hope it helped to find your way around the gallery module and its installation. Suggestions for improving this document are always welcome.