Upgrading Gallery2

Comments Off

The most reliable way to upgrade Gallery2 is to do a complete replacement.

To ensure a safer upgrade, it’s recommended that you deactivate or even uninstall all the plugins installed, and change the theme back to default theme of Gallery2 to Matrix.

Gallery 2 Plugins

Gallery2 Matrix Theme

Download and extract the latest version of Gallery2.

$ cd /var/www/
$ wget http://downloads.sourceforge.net/gallery/gallery-2.2.5-minimal.tar.gz
$ tar -zxvf gallery-2.2.5-minimal.tar.gz

I like to use symbolic links to help me easily replace older version with newer one.

$ mv gallery2 gallery-2.2.5
$ ln -s gallery-2.2.5 gallery2

Copy the existing g2data directory to the new Gallery2 directory e.g.

$ cp -R ./gallery-2.2.4/g2data_e76ab32e8b ./gallery-2.2.5

Run the install script by pointing your browser to the base url of your website (e.g http://gallery.vincentkong.com), which will bring you through an installation wizard to setup Gallery.

Gallery Installer

When the Storage Setup is reached, Gallery will ask to specific a directory g2data where all the images will be stored. Enter the same directory which was just copied previously.  e.g. /var/www/gallery-2.2.5/g2data_e76ab32e8b

Gallery 2 Database Setup Upgrade

When the Database Setup is reached.  Click on the “Reuse Existing Tables” button.

Gallery Database Setup Upgrade

When the Version Check is reached by the installer it will bring you to the Gallery Upgrader script, where you continue with the Upgrade wizard.

Gallery 2 Version Check

Gallery 2 Upgrade Welcome

In the Upgrading the Gallery Core Module it’s recommended to back the exist database before continuing. e.g.

$ mysqldump -u username -p gallery_database > gallery_database.sql

Gallery 2 Upgrade Core

The Upgrade Plugins is the final step in the upgrade process.

Gallery 2 Upgrade Plugin

Gallery 2 Upgrade Finish

Gallery2 URL Rewrite Plugin

Comments Off

By default Gallery uses web URLs which have question marks and lots of numbers in them which looks ugly. e.g. http://example.com/?g2_itemId=123

The URL Rewrite plugin enables you to configure URL patterns to more human readable.

To install the URL Rewrite plugin, go to Gallery Admin and click on the “Plugins” link to display the plugins already installed, and then the “Get More Plugins” tab. To display an available list of plugins which can be installed.

Installed Plugins

Gallery Plugins List

If this is your first visit, you’ll need to download the list of plugins first. When the list of plugins are displayed, go to the “Gallery” section and click the “download” link associated with “URL Rewrite” plugin.

When the plugin has been installed a status message “URL Rewrite plugin updated” will appear. Click on “Plugins” link again to see your installed plugins, the “URL Rewrite” plugin will appear in the “Gallery” section with a “disabled” status. Click on the “Configure” link to begin setting up the URL Rewrite plugin.

URL Rewrite plugin

There are two types of methods which can be used for the URL Rewrite plugin, Apache mod_rewrite or PHP Path Info. The difference is mod_rewrite will give you pretty links e.g. http://example.com/album-name, and PHP Path Info will give you almost pretty links e.g. http://example.com/main.php/album-name. I setup my URL Rewrite plugin with mod_rewrite


URL Rewrite Setup

Before you select the Apache mod_rewrite method it must be enable first. In Ubuntu run execute the following:

$ sudo a2enmod rewrite

In the Apache configuration file, the FollowSymLinks option needs to be enabled and the FileInfo needs to be allowed for the Gallery’s home directory.

<Directory /var/www/gallery>
    Options FollowSymLinks
    AllowOverride FileInfo
    allow from all
</Directory>

Then create a file in your Gallery directory named .htaccess and give it read/write permission.

$ cd /var/www/gallery
$ touch .htaccess
$ chmod 666 .htaccess

After click on the “Apache mod_rewrite” link to continue the URL Rewrite Administration setup with mod_rewrite, and click on the “Save” button when you are satisfy with the URL rewrite rules.

URL Rewrite Administration

For better security it’s recommended to remove write permission on the .htaccess

$ chmod 644 .htaccess

For more information refer to the Gallery2 Module Rewrite page.

Gallery2 Quickstart Guide

Comments Off

Gallery is an open source PHP web application that enables management of digital photos and other media.

Installing Gallery2

Download and extract the latest version of Gallery2, I choose the Minimal version

$ wget http://downloads.sourceforge.net/gallery/gallery-2.2.4-minimal.tar.gz
$ tar -zxvf gallery-2.2.4-minimal.tar.gz
$ cp gallery2/* /var/www/gallery

Create a database for gallery to use, for MySQL

mysql> create database databasename
mysql> grant SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON databasename.* TO 'username'@'localhost' identified by 'password'

Run the install script by pointing your browser to the base url of your website (e.g http://gallery.vincentkong.com), which will bring you through an installation wizard to setup Gallery.

Gallery Installer

When the Storage Setup is reached, Gallery will ask to specific a directory g2data where all the images will be stored. It is recommend that this directory is not web accessible, however if that’s not possible then add a randomize string to the end of the directory e.g. g2data_e76ab32e8b. Create the directory and set read/write permission to it.

$ cd /var/www/gallery
$ mkdir g2data_e76ab32e8b
$ chmod 777 g2data_e76ab32e8b

Storage Setup

Continue with the installation until the Create a config file step is reached, which then requires the config.php file to be created with read/write permissions

$ cd /var/www/gallery
$ touch config.php
$ chmod 666 config.php

After the installation has been completed, it’s recommended that write permission be removed from the config.php file.

$ chmod 644 config.php

Securing Gallery

It’s important to have the Gallery secure, here are a few things which can be done:

  • Prevent the viewing of the Gallery code by adding the following to the Apache configuration file or by creating a .htaccess in the Gallery root directory.
    <FilesMatch "\.(inc|class)$">
        Deny from all
    </FilesMatch>
  • If the g2data directory is web accessible it should be block from access with the following:
    <Directory /var/www/gallery/g2data>
        Deny from all
    </Directory>

For more information on securing Gallery refer to the Security Guide.

Troubleshooting

The thumbnails are not displaying for the albums.

  • To generate thumbnails Gallery2 requires the GD Library for PHP.  To install the GD Library in Ubuntu:
    $ apt-get install php5-gd
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in