Archive

Archive for the ‘Movable Type’ Category

Movable Type and Image::Magick

February 5th, 2008 Behzad No comments

Movable Type relies on a number of libraries and additional pieces of software to perform certain functions – especially where images are concerned. Thumbnailing and captcha both rely on ImageMagick to perform various feats of graphic trickery.

However, getting ImageMagick playing nicely with Perl and Movable Type is not always straightforward. If you’re on a good host, then this work may already have been done for you (leave a comment if you’re with a host that has this sorted out), but even good hosts don’t always get this right, and if you’re on a dedicated server, this is probably something you’ll have to do yourself – as I’ve just done with my MediaTemple (dv) server.

I’m documenting the steps I took to get this working – hopefully it will be useful to someone else (and me in the future, the next time I have to do this). Please note that the steps require that you have root access, and are for dedicated servers (or dedicated virtual servers), and you need to be running Linux – I’m using CentOS, but I’m pretty sure this works for any distro.

Ok – so first up, browse to mt-check.cgi and see whether Image::Magick is already there. It’s in the same directory as mt.cgi, so just replace with mt-check.cgi in your normal URL for MT.

If you’re lucky, and it’s already there, then you’re done. Congrats, and enjoy !

If you’re not lucky, then you’ll see somethinng like “Image::Magick. Your server does not have Image::Magick installed…”. Time to roll up your sleeves.

For new installtion of Image::Magick from source, refer to

http://behzad.nategh.com/cpanel-imagemagick-perl-module-installation-failure/

  • In an ideal world, we’d be done now. Unfortunately, it seems as if there are often some problems with where ImageMagick puts its libraries such that PerlMagick can’t find them.
  • Test by running mt-check.cgi again. If it’s working, congrats again – if not, read on.
  • Take a look at the error log (probably something like /etc/httpd/logs/error.log) and look for lines mentioning ImageMagick – chances are you might see something like this

[error] Can't load '/usr/lib/perl5/site_perl/5.8.8/.../Magick/Magick.so' for module Image::Magick: libMagick.so.10: cannot open shared object file: No such file or directory at /usr/lib/perl5/site_perl/5.8.8/.../DynaLoader.pm line 230.\n at /var/www/vhosts/xxx.xxx.com/httpdocs/test/perl/image_test.pl line 9\nCompilation failed in require at /var/www/vhosts/xxx.xxx.com/httpdocs/test

  • Basically this means that PerlMagick can’t find the ImageMagick libraries it needs. To resolve this issue:
    • Edit /etc/ld.so.conf and add /usr/local/lib below the last line.
    • Run ldconfig
    • You should now be done ! check by running mt-check.cgi again or by running this perl -MImage::Magick -e 1
  • If it’s still not working, you can try this kludgier way:
    • Check what libraries ImageMagic.so needs by running the following (you may need to change the path to match what you’re seeing in your own error.log file)

      ldd /usr/lib/perl5/site_perl/5.8.8/.../Magick/Magick.so

    • This might give you something like this:

      libMagick.so.10 => (missing)
      libWand.so.10 => (missing)
      libc.so.6 => /lib/tls/libc.so.6 (0xb7ca4000)
      libtiff.so.3 => /usr/lib/libtiff.so.3 (0xb7c57000)
      libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb7c39000)
      libbz2.so.1 => /usr/lib/libbz2.so.1 (0xb7c28000)
      libz.so.1 => /usr/lib/libz.so.1 (0xb7c18000)
      libm.so.6 => /lib/tls/libm.so.6 (0xb7bf4000)
      libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb7be2000)
      libdl.so.2 => /lib/libdl.so.2 (0xb7bde000)
      /lib/ld-linux.so.2 (0xb7fea000)

    • OK – so there are 2 libraries – libMagick.so.10 and libWand.so.10 that can’t be found. The chances are that PerlMagick is expecting to find these libraries in /usr/lib, instead of /usr/local/lib. So let’s put them there:

      ln -s /usr/local/lib/libMagick.so.10 /usr/lib/libMagick.so.10
      ln -s /usr/local/lib/libWand.so.10 /usr/lib/libWand.so.10

    • And that should be it. Run mt-check.cgi again, and you should now see that MT finally agrees that ImageMagick has been installed.

[Updated with a better initial method - editing /ld.so.conf which removes the need for the symlinks]

Good luck !!

cPanel Image::Magick Perl module installation failure

December 20th, 2007 Behzad No comments

It’s better to install from source as the versions are constantly changing and the dependencies too.

First remove any old RPM installations

# rpm -qa | grep -i Magick

# rpm -e anything that pops up.

Go to your favourite install directory (/usr/src) whatever

# wget ftp://ftp.imagemagick.org/pub/ImageM…eMagick.tar.gz

# tar xvzf ImageMagick.tar.gz

cd into the new folder (current version is ImageMagick-6.3.3)

# cd ImageMagick*

Configure it with whatever crazy stuff the customer needs:

# ./configure –with-x=no

OR

# ./configure –enable-shared –with-modules –without-x –with-gs-font-dir=default \
–with-perl=yes –with-xml=yes –with-zlib=yes –with-jpeg=yes ;

(And any other mindless stuff you feel like throwing in

# make && make install

From the folder you are in:

# cd PerlMagick

# perl Makefile.PL

# make

# make install

And you’re all done.

Credits to Stephanie_R at cPanel forums.

If you have problems after installtion please read http://behzad.nategh.com/movable-type-and-imagemagick/

BUT HOLD ON, this is not it yet!

We need to get it locked into PHP !

The new WHM has a fantastic utility to complete the task.

Log into WHM >> Software >> Module Installers >> PHP Pecl and install imagick to get the whole thing binding into PHP and making your applications gell ! :)