[lang]

Present Perfect

Personal
Projects
Packages
Patches
Presents
Linux

Picture Gallery
Present Perfect

Gallery Upgrade

Filed under: General — Thomas @ 08:52

2006-04-11
08:52

So, I've been delaying a certain problem for a few months now, hoping that any of my fellow monkeys at Apestaart would address the issue first. Of course, they were doing the exact same thing. And I guess I'm the first to cave in.

The issue is simple - our previous server was running Fedora Core 1, and I had a hacked-up Gallery 1.3 install in my website. Some of the others also were running various Gallery versions. At some point, our hosting company went bankrupt and got taken over by another one, and in the process we migrated to a Fedora Core 4 server. That migration was mostly succesful, save for two problems - Gallery 1.3 doesn't work with PHP 5 (the version shipped in FC4), and all my personal CVS history was deleted.

Having more or less dealt with the second issue before, it was now time to attack the first. Have I mentioned before how much I hate web software ?

So, after browsing the docs for Gallery, and noticing they have a largely rewritten Gallery2 which looks very nice, has unit tests (!), and seems to be decently put together, I started looking for upgrading documentation. And after some puzzling, it seems that my best bet is to upgrade from 1.3 to 1.5, then verify integrity, and then jump to version 2.

There's one slight problem - for the upgrades to work, I need to actually verify the current version works, and then run the upgrade to 1.5 through PHP - but the current site doesn't run on PHP5. The images take over 5GB at the moment, so copying everything over to a different machine and do the upgrade there isn't feasible either.

While pondering if I should rebuild apache and php by hand, it hit me that I could just use mach to set up an FC3 chroot, install apache and php, copy my site into the chroot, run apache on a different port, and do the upgrades step by step. Ten minutes later, I had completed the first step of the upgrade.

For future reference, here's what I did:

yum install mach
mach -r f3c setup
mach -r f3c yum install apache php vim-enhanced
mach -r f3c chroot

- copy site into chroot, change /etc/httpd/conf/httpd.conf to run on port 8080 and point to the copied site

httpd -X

(because doing 'service httpd restart' would make it kill the host's httpd as well)
- access the site, notice that it stops httpd, check the log and figure out why

cd /dev
mknod random c 1 8
mknod urandom c 1 9
httpd -X

- access the site again, notice that everything works except logging in
- edit php.ini and turn register_globals On, login then works
- overwrite current gallery with gallery-1.5.2pl2
- go to site, notice gallery tells me to upgrade, but that gives me a blank page
- edit config.php, remove some of my customizations, redefine some vars, run again, upgrade now works
- turn off register_globals (because the upgrade wizard then complains about it, good)
- notice errors in the config, and:

yum install netpbm-tools unzip

- Finish the upgrade wizard
- go to gallery page and see the "httpd -X" crash again
- look at error log, notice it ran out of memory, and update php.ini to use 32M instead of 16M
- access site again, Gallery informs me my albums are out of date and I should upgrade them, which I do
- after some waiting, the upgrade is done, and (beside the horrible theme) my gallery seems to be ok, just like before
- go to tools/find_orphans.php, repair
- go to tools/validate_albums.php; this ran fine

At this point, I had a working Gallery 1.5, and it was time to move the whole tree back into the original host's web directory, and finish the migration to Gallery 2.1 there.

- use the multisite option to put a gallery in my website dev tree
- create MySQL tables (Gallery 1.3 worked completely database-free, but this is not possible anymore - too bad)
- disable GD as requested by the upgrade manual
- create test album, upload test photo, notice thumbnail missing
- this is because by disabling GD, none of the graphics toolkits were activated. Activate ImageMagick
- Gallery warns me about a vulnerability, which it links to. Nice ! I double-check if my ImageMagick RPM has a patch for this (rpm -q --changelog ImageMagick) - it does: "fix a denial of service in the xwd coder (#158791, CAN-2005-1739)"
- proceed with this version
- recreate thumbnails, twiddle with settings, until there are thumbnails for the test photo

At this point, Gallery 2 is working correctly, and now it's time for the big upgrade. MAKE SURE YOU HAVE A BACKUP.

- For the import, increase your PHP memory limit. I used 64M (because an initial run with 16M stopped running after a minute, leaving me with only part of the albums imported, annoying)
- In Site Admin, choose "import from Gallery 1"
- I chose to set Title from blank, and Summary from Caption (because a test import had some captions that were too long to serve as title and got truncated)
- Nice progress bar, everything works well, and the upgrade finishes with around 33MB used for close to 4000 pictures.

All in all, this worked a hell of a lot better than I expected it to. Gallery is a pretty impressive web application, and the user experience I got from it was amazing - I was able to upgrade from a version from 2002 all the way to the latest without too many problems. I don't think I've ever seen a web app take this much care of its users.

Next on my list - migration of Rombocop and other Apestaart sites with Gallery.

1 Comment

  1. […] A few months ago I used mach to upgrade an old Gallery install, taking it from PHP4 to PHP5. Today I wanted to hack on buildbot some more, and when trying it on my local SVN test repository I noticed that the repository was borked. Apparently it was once created with BDB 4.2, while my laptop is now using FC5 with BDB4.3. Gotta love Berkley. […]

    Pingback by Present Perfect — 2006-06-10 @ 22:09

RSS feed for comments on this post. TrackBack URL

Sorry, the comment form is closed at this time.

picture