Installing Gallery2 In Drupal

How do we keep this site running? This post may contain affiliate links — the cost is the same to you, but we get a referral fee. Compensation does not affect rankings. Thanks!

Installing gallery2 In DrupalGetting gallery2 to work in Drupal (embedded) can be very frustrating. This guide has been updated for Drupal 5.x and the new Drupal gallery module.

First, download the Drupal gallery module from the Gallery Project page (note that while the new gallery module listed above contains improvements over the old one, at the time of this writing it was still in beta phase, meaning it may not work), and upload the “gallery” folder into your modules directory. Don’t activate the module yet – we’ll be doing this after installing Menalto’s Gallery.

Installing Gallery2 in Drupal

Download Gallery

Obtain the latest Gallery release by visiting and downloading the latest release. The main difference between the versions (from typical to developer) are that the more loaded versions come with more modules, which you can always add later. Make sure the “Image Block” and “ImageFrame” modules are included (with the “typical” installation they’re not, but you can download them on the Gallery2 official modules page).

Extract the Menalto Gallery into a folder called “gallery2” inside your Drupal installation (we recommend drupal/modules/gallery/gallery2 to avoid location issues). Make sure you don’t name the directory “gallery” as this may conflict with Drupal’s gallery module. This may take a while to upload via FTP. For those that want to ensure that files don’t get lost by interrupted FTP sessions, we recommend you check out the Gallery2 Preinstaller (or make sure your FTP client resumes broken sessions – in Smart FTP this can be accomplished, for example, by clicking “Queue/ Direct Transfer” before uploading files).

(Optional) Disable .htaccess

Only follow this step if experiencing problems: We had problems with rewrite settings interfering with my Menalto Gallery installation – in particular, we were not able to get past step 3 in the installation process (clicking the “next step” button – which calls a JavaScript function, simply did nothing). To solve this problem we temporarily disabled (renamed) .htaccess. Make sure you put it back when you’re done and only follow this step if you’re experiencing the same problem.

Install Menalto Gallery

Browse to the /gallery2/install/ folder and installation should begin automatically. When you get to the step asking you where to install g2data, make sure to install it in a non-public directory (above your “public_html” or “www” folder, ie. above the root), and CHMOD the directory’s permissions to 777.

Security Settings

Once installation has completed, make sure you CHMOD permissions on /gallery2/config.php back to 644. In addition, create an .htaccess file within the /gallery2/ folder containing the following:

<Files ~ "\.(inc|class)$">
   Deny from all

Finally, you’ll want to CHMOD permissions on your /gallery2/ folder to 555 (unwritable).

Multisite Installations

If you already have your Drupal sites setup in a multisite configuration, getting gallery2 to work with them is a breeze. Simply select “Multisite Installation” in step 3, and then type in the path (where = primary drupal installation)


where “drupal” is the directory of your primary Drupal installation (multisite codebase that other multisites run off of). Each time you wish to install gallery2 in one of your multisites you simply run the gallery2 installation from the primary path and update the URL above in step 3 to install the new multisite.

Menalto Gallery Settings

Once you have finished installing Menalto Gallery, log in and make sure “Image Block,” “Image Frame” and “URL Rewrite” plugins are installed and activated (log in to your Gallery2 installation, click on “site admin” and then “plugins”). For the URL Rewrite plugin, select “Apache mod rewrite” and CHMOD your /gallery2/.htaccess file to 666 to pass the tests. Click done if both tests are successful, and then click “activate” next to the “URL Rewrite” plugin to activate it.. If you downloaded a package below the “full” version you may need to download and install these modules separately. Finally, deactivate the “Registration” module if it is active. All registration will now be done via Drupal.

Log Out Of Menalto Gallery

Log out of Menalto Gallery before proceeding to avoid Drupal integration issues.

Embedding Gallery2 in Drupal

Drupal 5.x

Install and Configure Drupal’s gallery module

Browse to site building -> modules -> list and activate the gallery and gallery menu modules. Then go to site configuration -> gallery settings -> install. If you installed /gallery2/ outside the /modules/gallery/ directory you’ll need to adjust the location settings. You’ll also want to “sync” your users (this may take a while if you have a large Drupal user database). Once everything “OK’s” enable the “gallery” blocks and you’re good to go!

Drupal 4.7.x

Install and Configure Drupal’s gallery module

Browse to admin -> modules -> and enable the “gallery” module. Then go to administer -> settings -> gallery and enter the following:

For Single Installation

  • URI of Gallery2:/modules/gallery/gallery2/
  • Location of Gallery2: /home/root-name/public_html/modules/gallery/gallery2/
  • Embed URI:/index.php?q=gallery

For Multisite Installation

  • URI of Gallery2: /sites/
  • Location of Gallery2: /home/root-name/public_html/sites/
  • Embed URI: /index.php?q=gallery

You may leave “autodetect” selected and click “save configuration”. If for some reason the path resolves to an error but you are able to access the path via your browsers, ensure that you haven’t password protected (using “web project” in cPanel, for example) the directory. If so, temporarily unprotect it to proceed.

Getting URL Rewrite to Work

At this point everything should setup successfully but you may still receive an “Advisory” for the URL Rewrite module. This is normal, as this module needs to be configured first. Browse to admin -> settings -> gallery. Expand “Links to Gallery2 Site Admin sections most relevant to Drupal (advanced)” and click on “Embedded URL Rewrite settings.” On the next screen you’ll be specifying a new .htaccess file. I typically put this in the gallery2 directory (ie. CHMOD the file to 666, and specify the paths as follows:

Htaccess path: modules/gallery/gallery2 Public path: //

If the Apache gods are on your side you should see the green message “Successfully saved settings” at top. Voila You can double-check your setup by clicking on the “test” tab. You should see a green “success” at top right indicating a successful pass of all three tests. Finally, you can now browse to “URL Rewrite” under “Admin Options” at left to configure the Rewrite settings.

Enable Drupal Gallery Blocks

Enable the “Gallery Block” in administer -> blocks, and optionally the “Gallery Navigation Block” and the “Gallery Grid Block”.

Access Control

Make sure you enable access for an “all access” type profile that you are enabled for (the default admin profile may not give you access) and grant access for the gallery module to enable “access standalone g2image.”

Accessing the Gallery

Click on “gallery” in your account’s admin block to access the gallery. If it was embedded correctly you should see links to “site admin” in the top right corner, “add photo” in the center, and “edit” in the bottom left. If you don’t see these links you may be logging in with a non-administrator role. In which case you should log out, log back in as administrator, and add the corresponding users by selecting “members” next to “Site Admins” from within embedded gallery2’s “Groups” menu item. If this doesn’t solve your problem, and certain functions (such as creating an album), don’t work, check your .htaccess file for a unique situation in which you may be rewriting index files:

# rewrite index pages

#RewriteRule ^index\.(htm|html|php) // [R=301,L]

#RewriteRule ^(.*)/index\.(htm|html|php) //$1/ [R=301,L]

In my situation this was interfering with Gallery2 rewrite rules. Commenting these lines out fixed the problem and I was able to edit and create albums, delete photos, etc.

Alex bring a series of in-depth articles on search marketing and content management systems as well as troubleshooting tips to We Rock Your Web's collection. He is an avid tennis player, nature enthusiast, and hiker, and enjoys spending time with his wife, friends, and dogs, Bella and Lily.

Leave a Reply

7 Comments on "Installing Gallery2 In Drupal"


This is a great article, I’ve been running Gallery2 on Drupal 6 for years! Have you had any luck embedding Gallery2 on Drupal 7?


Can anyone tell me what the “Gallery 2 URL or URI” and “Gallery base (optional)” settings need to be? I’ve tried various settings from:


and everything in between. Some settings appear to work in terms of the Drupal install giving an OK status, but navigating to the Gallery from the admin sidebar produces a Page Not Found.

I’m working with D6.12 & Gallery 2.3



I now believe that my problem is related either to my previous post – or the Step 4 where I have to define the public path to the .htaccess file.

My Public path to .htaccess file is set to:


and Filesystem path is set to


but when I try to navigate to Gallery through the Drupal Admin sidebar navigation menu I get Page Not Found because the URL it is looking for is http://gallery – which obviously is not right.



This might be an old article, but I was able to get Gallery2 working with drupal 6.4. The only two problems I encountered were that I had to make .htaccess temp write access. I also needed to use gallery2.3 RC.


Hi there,

Yes, this article was written back for Drupal 4.x. Thanks for testing it out with Drupal 6.x! I’m glad to hear it will works (for the most part) Hopefully I’ll have time to update this article soon.


Thanks for putting together this helpful guide for drupal and gallery integration. I had hacked together a solution with 4.7, and then after upgrading to 5.0 I couldn’t get my gallery2 settings quite right for integration. This page helped me get things back up and running.


Send this to a friend