Installing Imagick extension for PHP in Ubuntu 7.10

I already have ImageMagick installed in my machine and I tried to install the Imagick extension for PHP but I was stuck with strange errors. I have spent couple of hours today to figure out what I did wrong and Why I cant build that extension. Finally I’ve figured out that I must install ImageMagick from source first to build that extension. Heres how to

1. You have to install ImageMagick from source and Its a Must. Otherwise the extension for PHP wont compile. It will show you a strange error like magic_wand.h not found.

wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar zxf ImageMagick.tar.gz
cd ImageMagick-6.3.8
./configure
sudo make
sudo make install

2. Now download the Imagick extension source from pecl.php.net – I tried imagick-2.1.0RC3

wget http://pecl.php.net/get/imagick-2.1.0RC3.tgz
tar zxf imagick-2.1.0RC3.tgz
cd imagick-2.1.0RC3
phpize && ./configure
sudo make
sudo make install

This will make compile imagick source and build imagick.so – In my machine, I found imagick.so in the following directory

/usr/lib/php5/20060613+lfs

3. Now add “extension=imagick.so” in your php.ini (You may need to write the full path of imagick.so based on your configuration)

4. Restart your web server and thats it

Look at the php ini – you will see something like below (Click to enlarge)

Imagick