Drupal6.8 + Gallery2.3 + G2Image WORKING

thermador

Joined: 2008-12-11
Posts: 5
Posted: Fri, 2008-12-12 21:15

Here's how you do it:

Implementing Drupal 6.8, Gallery2 2.3 and G2Image 3.03 on 1and1 shared hosting

Note: Some of these steps may not apply to you, this is just what I had to do to get it installed on 1and1 shared hosting. Since 1and1 is the largest hosting provider in the world, and also one of the cheapest, some of this may be relevant to you. Also, on my real sites, I use a lot more Drupal modules than this, I’m just doing a bare-bones example here.

IMPORTANT: When I specify directories (files go in) I am saying where the FILES go, not the FOLDER. I did it this way to be more specific. So, for example, when I installed Drupal in the folder /drupal6/, you will find index.php in /drupal6/index.php and NOT in /drupal6/drupal-6.8/index.php

Note: This tutorial assumes that you just disable URL Rewrite for Gallery. If you want to try and get it working, read my post below (worked for me) or read this thread: http://gallery.menalto.com/node/81643

Part 1: Download some files and put them on your server

Drupal v6.8
Drupal (www.drupal.org)
- files go in /drupal6/
(for me anyway, this is my root folder for this installation)

Drupal Modules Required
TinyMCE WYSIWYG Editor 6.x-1.1-dev (http://drupal.org/project/tinymce)
- files go in /drupal6/sites/all/modules/tinymce/

Gallery 6.x-1.x-dev (http://drupal.org/project/gallery)
- files go in /drupal6/sites/all/modules/gallery/

Addons for TinyMCE Module:
TinyMCE WYSIWYG Editor v3.2.1.1 (http://tinymce.moxiecode.com)
- files go in /drupal6/sites/all/modules/tinymce/tinymce/

G2Image 3.03 stable (http://g2image.steffensenfamily.com)
- files go in /drupal6/sites/all/modules/tinymce/tinymce/jscripts/tiny_mce/plugins/g2image/

Gallery2 v2.3
Gallery2 v2.3 FULL version (includes all modules) (http://www.gallery2.org)
- files go in /drupal6/gallery2/

Addons for Gallery2
NetPBM – follow download link and instructions on this page (http://codex.gallery2.org/Installing_an_Image_Processing_Library)
- download the appropriate version for your server. If you are using cheap 1and1 hosting, you need the Linux Intel (netpbm_gallery-1.4-pl2-linux-intel.zip). Otherwise follow the installation instructions to determine what version you need.
- files go in /drupal6/gallery2/netpbm
- make sure to set the permissions on the netpbm folder and all files in it to CHMOD 755, otherwise NetPBM won’t work. Google CHMOD and CHMOD Calculator if you’re unfamiliar with this stuff.

Drupal Modules (Optional)
Nice menus 6.x-1.3 (http://drupal.org/project/nice_menus)
- files go in /drupal6/sites/all/modules/nice_menus/
- makes going through all the admin and drupal setup much faster

Drupal Setup

Setting up Drupal is covered thoroughly at www.drupal.org.
The rest of this info is for 1and1 users (may be relevant to others):

1) 1and1 users, go to the 1and1 control panel and create a new MySQL v5.0 database. Note that during drupal setup, you will have to specify a specific database server and NOT just ‘localhost’. This information is all in your 1and1 control panel.

2) Create a copy of /drupal6/sites/default/default.settings.php and name it settings.php (in the same folder).

3) Now, go to your site to begin the Drupal setup process. Access it from the domain that you want to use. Example:

IMPORTANT - Do not go to: www.myoldsite.com/drupal6 or www.myserver.com/drupal6
Go to: www.mynewdomainname.com instead

For example, if people will access your site from www.myfamily.com but is actually hosted at www.mypersonalsite.com/myfamily/ then you should type www.myfamily.com into your web browser when you go to set up drupal.

4) Choose your language

5) If you’re on 1and1 you’ll need to fix the register_globals problem. Here’s how:

Create a new file called php.ini (notepad will work for this) and add the lines:

Quote:
register_globals = Off;
memory_limit = 32M;

note: if you still find yourself running out of php memory, you can up the limit. I haven’t had any problems so far. see the post below for more info on setting up php.ini

Put the php.ini file in your main drupal directory /drupal6/

6) Recommended: If you’re on 1and1, your server defaults to using php4. You should probably be using php5, so you should edit the .htaccess file in /drupal6/ and add the following lines (at the bottom is fine) to force 1and1 to use php5:

Quote:
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php

7) Enter the database name, username and password. Click on “Advanced options” and replace “localhost” with your database server (req. if you're using 1and1 shared hosting). Click save and continue.

8) Fill out your site’s name and info. You’ll notice that Clean URLs are disabled (if you’re using 1and1 anyway, they may automatically work for other web hosts). Here’s how to get them to work at 1and1.

Just open up /drupal6/.htaccess and then find the following line:
# RewriteBase /drupal
If you’re going to access drupal from a folder (www.mysite.com/drupal6/) change it to
RewriteBase /drupal6
If you’re running drupal from the root of a domain (www.mysite.com) change it to
RewriteBase /

That’s it! Save your new .htaccess and hit refresh in your web browser. Drupal’s installer should now have Clean URLs enabled automatically. Continue onward…

Setting up Nice Menus (optional)

Enable the Nice Menus module. Set up the Nice Menus blocks if you are using them – add the block, configure it, and choose source menu tree = Administer from the drop down. You can also disable Administer from the Navigation menu by going to Site Building -> Menus -> Navigation and then removing the checkmark from the box next to Administer.

The end result is a separate Admin menu that is a lot faster to navigate.

Setting up Gallery2

Using your web browser, go to www.mysite.com/drupal6/gallery2 or www.mysite.com/gallery2 (depending on how you’re accessing your site. Must be the same as what you did for the drupal install above, see earlier examples).

This will begin the Gallery 2 installer.

Step 1) Go through the authentication process as described. It’s easy. If you’re on 1and1 shared hosting, amazingly, all your system checks should go through Ok, so continue onward to step 3. Otherwise see the Gallery Codex.

Step 3) Choose standard install. I don’t mess with multisite ;-)

Step 4) IMPORTANT. Gallery2 will show you your FULL path in the Directory Path box. Copy this down (save it to a text file) cause you’ll need it later.

Anyway, follow the instructions, create your g2data subfolder (in this example, I created /drupal6/gallery2/g2data/

Set the permissions to 777, which means that on a windows machine, you click all the boxes. Google CHMOD and CHMOD Calculator if you’re unfamiliar with this stuff.

Step 5) Using your 1and1 control panel, create another blank database (MySQL 5 will work fine) and enter the hostname, username, password, database name, etc. You can leave the table and column prefixes the same. Remember that 1and1 takes a few minutes to set up a new database, so just be patient until your database is ready. Once 1and1 says your database is ready, click “Save” and move on to step 6

Step 6) Enter admin info. For ease of use and installation, enter the SAME admin info for gallery as the admin info for drupal.

Step 7 and 8 just wait for it to do its thing.

Step 9) Plugins. You can change these later. I recommend starting fresh and disabling ALL plugins except for the required ones: 'Image Block' and 'Image Frame'

You should also enable:
‘NetPBM’ pretty much required for thumbnails - and you already copied the NetPBM binaries to your server and set their permissions to 755, right?
‘Search’ useful for searching the gallery
‘User albums’ if you want users to be able to create their own albums. Make sure to configure it after it’s installed and check the “show link” box. To configure gallery from within Drupal, hit the Gallery link and then hit “site admin” in the corner.
'URL Rewrite' --
You don't have to enable Gallery2's URL Rewrite, but if you do, you probably want to read the instructions in the post below for setting up URL Rewrite so that all your menus still show up.

Continue to Step 10, choosing "Activate". Click on through and you’re done!

Drupal Module Setup

Once drupal is up and running, and Gallery2 is installed, you need to configure some Drupal modules. All your work is within Drupal at this point (as well as editing some files on your server), so you don’t need to be in the Gallery2 interface anymore – all of that will be available through Drupal.

Go to Administer -> Site Building -> Modules and enable these modules

TinyMCE (1 module)
Gallery2 (four modules)

Go to Users -> Permissions and make sure that the right users have access to gallery content and can use TinyMCE.

Setting up Gallery2 – The Drupal Module

Thankfully, this module tells you what it needs to work. Go to: Site Configuration -> Gallery Settings.

1) Checks your php memory limit. This should be set in php.ini already (see above).

2) Checks locations. For my site, this was /drupal6/gallery2/ Leave the gallery base set to ‘gallery’

3) Checks drupal modules and gallery plugins. Ignore the bit about URL Rewrite until that is fixed. Hopefully soon! If/when it works, you just have to enable the URL Rewrite module within the Gallery2 settings. Depending on how you want your site to work, you may want to enable the ‘Profile’ module and other recommended modules.

4) Clean URLs / URL Rewrite Settings – SKIP IT until it gets fixed in a future version

5) Initial User Sync. Just click the “Sync” button and you’re done. This is a fresh install, so I didn't have sync issues.

Set up the Gallery2 Drupal Block

Go to Site Building -> Blocks and enable the “Gallery Navigation” block.

You can customize the look of it by going to Gallery -> Site Admin -> Themes -> "Blocks to show in the sidebar" section

Setting up TinyMCE & G2Image

Before you can get the G2Image button to show up in TinyMCE you’ve got to edit some files manually.

Find the file: /drupal6/sites/all/modules/tinymce/plugin_reg.php
And open it in an editor. Add the following lines

Quote:
$plugins['g2image'] = array();
$plugins['g2image']['theme_advanced_buttons2'] = array('g2image');

I added them at the end, just before the return, so the end of my file looks like this:

Quote:
$plugins['zoom'] = array();
$plugins['zoom']['theme_advanced_buttons2'] = array('zoom');

$plugins['g2image'] = array();
$plugins['g2image']['theme_advanced_buttons2'] = array('g2image');

return $plugins;
}

Save plugin_reg.php and upload to your server.

Setting up TinyMCE

Assuming you put all your files in the right place at the beginning, and you’ve set up permissions for TinyMCE, go to Site Configuration -> TinyMCE. Create a new profile. There may be an error on this page about an invalid argument. I ignored it ;-) My arguments are always valid.

Go through the settings carefully and set up TinyMCE the way you want it. In the ‘Buttons and Plugins’ section, you’ve got to select all the buttons you want that profile to have access to. The main one we’re concerned with is “g2image.” Make sure that one is checked. Other useful buttons are:

cut, copy, paste, bold, italic, underline, strikethrough, justifyleft, justifycenter, justifyright, bullist, numlist, undo, redo, link, unlink

You can disable the default ‘image’ button or leave it, it’s up to you.

Getting Drupal’s Gallery Module to talk to G2Image

Go to Site Configuration -> Gallery Settings and then the G2Image button at the top.

Choose Mode: TinyMCE.

You may want to set “Default Action” to “Thumbnail with link to image”

Save configuration.

That should be it!

I just did this all this morning just as I've described and it works fine. I put it through the paces with several new user accounts, albums, and blog posts with images from the gallery.

You can always customize Drupal, add modules, customize the way gallery works and add plugins to gallery (by going to Gallery and then hitting “site admin” link in the corner) and so forth. This was just a bare bones install (and yes, I actually did this install as I was writing this.)

Also, when inserting images with G2Image, make sure that you’re hitting the insert button (lower) rather than the top insert button which inserts a filter thing rather than the image itself.

A word on themes

The default Drupal them doesn't work all that well with Gallery, so you may want to try something else. Usually a fixed width theme is going to work better, otherwise you'll probably end up with gallery spilling over the edge of the Drupal theme - this happens with Drupal's default theme.

For my main site, I use Marinelli 6.x-2.6 (http://drupal.org/project/marinelli) which has a lot of neat features. If you only use the left sidebar, gallery fits pretty much perfectly in this theme. Otherwise, I'm sure you can find something that works.

Enjoy!

 
thermador

Joined: 2008-12-11
Posts: 5
Posted: Tue, 2008-12-16 18:10

Important Security Update

I forgot to mention that by default, your /gallery2/ folder is public, and so are the albums in it. Make sure to set your permissions properly.

For example, if you're running a Drupal site that's entirely private, anything you add to the gallery can still be accessed by the public by typing in www.yourdomain.com/gallery2 using the Gallery2 interface.

For private sites, you need to edit the permissions of your main album and remove the "Everyone" group from having access. Strangely, if you add the "Registered Users" group as having access (Permission = "View all versions"), the public will still be able to access the site.

What you should do if you are running an entirely private site is create a new Role (let's say you called it "site users") in Drupal that has the same permissions as Drupal's Role "Authenticated User." Then go into the Gallery2 permissions and give only that new role permissions to access the main gallery.

 
thermador

Joined: 2008-12-11
Posts: 5
Posted: Tue, 2008-12-16 18:08

Setting up Gallery2's URL ReWrite Plugin

Here's what I did (all through the embedded Gallery2 interface in Drupal). I already had all the features of Gallery2 working within Drupal 6.8, the only problem was that the menus would disappear in sub albums when I had URL Rewrite enabled in Gallery2. Therefore I had disabled URL Rewrite in Gallery2. However, I happened upon a solution to this problem, which has to do with the order of installation.

1) "Install" URL Rewrite plugin for Gallery2 (Gallery -> Site Admin -> Plugins -> scroll down to URL Rewrite -> Install)

2) Configure URL Rewrite plugin (Gallery -> Site Admin -> Plugins -> scroll down to URL Rewrite -> Configure)
- a) Select Apache mod_rewrite and then in the setup:
- b) Absolute path to the folder of your embedded .htaccess: Put the absolute path of your Drupal installation here, for example, "/homepages/01/1234567890/htdocs/mysite"
- c) Please enter the Url to your environment: Just put a "/" here assuming you're using a domain
- d) Save the settings

3) Activate the URL Rewrite plugin (Gallery -> Site Admin -> Plugins -> scroll down to URL Rewrite -> Activate)

4) Once URL Rewrite is activated, refresh the embedded Gallery2 Site Admin page and click on "URL Rewrite" in the left hand menu (instead of scrolling down to it in the list like you were before). As discussed here (http://codex.gallery2.org/Integration:Drupal) you have some changes to make under the "Rules" tab of the URL Rewrite options.
- a) Only have "show item" enabled
- b) Set the "show item" URL Pattern to: "gallery/v/%path%" instead of "v/%path%"
- c) Save the settings

So far, it still didn't work. Then I tried this - reinstalling the Gallery2 Drupal Module.

4) Go to "Administer" -> "Site Configuration" -> "Gallery Settings"
- a) Click on the Install tab
- b) Go down to the bottom and click "Reset and Restart"
- c) Go through the installation again
-- i) PHP Mem test.

-- ii) Gallery2 Location settings. I used the auto settings:
Gallery2 URL or URI: "/gallery2/"
Gallery base (optional): "gallery" <- note that this has to be the same so that "gallery/v/%path%" will work
Once you're done hit 'test location settings' to move on

-- iii) Let's hope all your modules are already set up properly

-- iv) Public path to your .htaccess file: set it to "/" assuming that's true for your site
Filesystem path to your .htaccess file: set it to same as above but with a slash on the end, for example "/homepages/01/1234567890/htdocs/mysite/"
Once you've done that hit "configure url rewrite plugin" to proceed

-- v) Hit 'sync users / groups' to proceed.

 
thermador

Joined: 2008-12-11
Posts: 5
Posted: Fri, 2009-03-06 17:20

Setting up 1and1 shared hosting for Drupal + Gallery2

I thought I'd put this in a separate post, since there is more that I didn't cover above.

.htaccess (both files, one in Drupal root AND one in the /gallery2/ folder)

added the following lines at the bottom to force php5 - this will really speed up your drupal site as well as the gallery2 part of it.

Quote:
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php

php.ini (in Drupal root)

added the following lines to
a) install drupal properly on 1and1 shared hosting
b) make sure you have enough php memory available - I set it at 64 megabytes to make sure I had enough. You can set this at whatever you want, but I needed it at 32M before I could run drupal and gallery2
c) change the upload file size limits. this gives a 10 megabyte limit per file. default for most servers is 2M, which is not enough for higher quality photos.
d) change the batch upload limit. this sets the maximum you can upload in one batch. 40M could be four 10M files, or eight 5M files. again, you can set it at whatever you want.

Quote:
register_globals = Off;
memory_limit = 64M;
upload_max_filesize = 10M;
post_max_size = 40M;

 
Zcubed
Zcubed's picture

Joined: 2006-08-31
Posts: 2
Posted: Thu, 2008-12-18 20:46

Very through! Thanks

 
thermador

Joined: 2008-12-11
Posts: 5
Posted: Fri, 2009-03-06 17:15

bump to the top... here for your information

note that when you upgrade drupal versions (i.e. 6.8 -> 6.10), after the upgrade is complete you need to go to "Administer -> Site Config -> Gallery Settings", go the the "Install" tab and click on "Reset and Restart" at the bottom, and go through the process described in my last post about URL rewrite.

Otherwise, your gallery probably won't work after the upgrade.