From YobiWiki
Jump to: navigation, search



On sql vserver

mysqladmin -uroot -p create gallery2
mysql gallery2 -uroot -p -e"GRANT ALL ON gallery2.* TO IDENTIFIED BY 'gal_long_pwd'"

On public vserver

apt-get install gallery2
   sql host:
   admin user to create dbs: admin_gallery2 / gal_long_pwd

/etc/gallery2/apache.conf: uncomment first line alias /gallery2 OR create vhosts as suggested in the last lines but don't do both at the same time.

If you use virtual hosts

mv /etc/apache2/conf.d/gallery2 /etc/apache2/sites-available/
ln -s /etc/apache2/sites-available/gallery2 /etc/apache2/sites-enabled

Otherwise this gallery virtualhost will be the one by default

apt-get install locales

activate locales you want for gallery, in their ISO form, not UTF8

apt-get install dcraw jhead zip unzip libjpeg-progs php4-gd ffmpeg imagemagick
/etc/init.d/apache2 reload

Be sure both hosts know each other via e.g. /etc/hosts

create /usr/share/gallery2/.htaccess with

php_value memory_limit 64M

Prepare directory for the albums

mkdir /home/gallery2
chown www-data:www-data /home/gallery2

Go to
Choose Mysql with transactions and give the credentials

Gallery migration

Once you have migrated your Gallery1 to Gallery2 with the migration module

Enable URL Redirection under Apache webserver:

Ensure the mod_rewrite Apache module is enabled:
a2enmod rewrite
/etc/init.d/apache2 force-reload
  • Enable the module URL Rewrite in Gallery2
  • URL Rewrite administration -> Rules -> Migration -> activate
  • If you have troubles with url rewrite, especially if you touched the directory structure or established vhosts, deinstall completely the URL Rewrite module and reinstall it.

PG Theme


Gallery1 used to use jpegtran to rotate automatically imported images in a lossless fashion.
Gallery2 doesn't :-(

You can install the module jpegtran for Gallery2

  • Uncompress it in /usr/share/gallery2/modules
  • Install it and activate it under the administration view of Gallery2
  • Install jpegtran (libjpeg-progs under Debian)
  • Test it under the administration view of Gallery2, there is a new jpegtran shortcut in the graph tools menu

Now this module does not automates anything when importing images but at least when you rotate manually a picture, it'll use jpegtran instead of the fat slow lossy ImageMagick rotation.

For rotations when importing, I do it with gthumb:

  • select all images (including those already with the correct orientation, don't bother selectiong only those to be rotated ;-) )
  • Tools -> Rotate Images -> + Adjust photo orientation + Apply to all images -> Apply



Create directory /usr/share/gallery2/themes/<mytheme>/templates/local
Copy /usr/share/gallery2/themes/<mytheme>/templates/theme.tpl to /usr/share/gallery2/themes/<mytheme>/templates/local/theme.tpl, edit that copy and add just above the </body> tag the Piwik javascript

You can also clear the template cache, cf

Gallery2 error on missing plugins

I don't know exactly when but with v2.3.1.dfsg-1 (debian), gallery2 failed to add new pictures with an error about a missing file uploadapplet/
Even by launching manually the /upgrade once again it wasn't working still.
I had to edit manually the DB to remove references to that plugin and another one also linked to the Gallery Remote:

DELETE FROM `gallery2`.`g2_FactoryMap` WHERE `g2_FactoryMap`.`g_classType` = 'ItemAddPlugin' AND `g2_FactoryMap`.`g_className` = 'ItemAddUploadApplet' AND `g2_FactoryMap`.`g_implId` = 'ItemAddUploadApplet' AND `g2_FactoryMap`.`g_implPath` = 'modules/uploadapplet/' AND `g2_FactoryMap`.`g_implModuleId` = 'uploadapplet' AND `g2_FactoryMap`.`g_hints` = 'N;' AND `g2_FactoryMap`.`g_orderWeight` = '5' LIMIT 1
DELETE FROM `gallery2`.`g2_FactoryMap` WHERE `g2_FactoryMap`.`g_classType` = 'ItemAddPlugin' AND `g2_FactoryMap`.`g_className` = 'ItemAddGalleryRemote' AND `g2_FactoryMap`.`g_implId` = 'ItemAddGalleryRemote' AND `g2_FactoryMap`.`g_implPath` = 'modules/remote/' AND `g2_FactoryMap`.`g_implModuleId` = 'remote' AND `g2_FactoryMap`.`g_hints` = 'N;' AND `g2_FactoryMap`.`g_orderWeight` = '5' LIMIT 1

Then in the Administration interface, go to Maintenance and clean the DB cache.

See also Debian bugs #573168 and #573842

Personal tools