Install imagemagick as PHP extension in Debian without apt

Written by - 0 comments

Published on October 6th 2012 - Listed in PHP Linux


I recently wanted to install imagemagick as a php extension on my Debian Squeeze web server. Unfortunately most existing howtos just install it through apt-get install php5-imagick, which of course requires that php itself was also installed trough apt-get. Doesn't fit my case, because I like to build my own PHP :-).

So here's another guide how imagemagick can be installed as a PHP extension on a Debian system (currently Squeeze).

Install pre-requirements (the imagemagick libraries and development files):

apt-get install imagemagick libmagickwand-dev

This will install a ton of dependency packages... As an alternative you can also grab the source code file of imagemagick and compile it yourself.

Now download the PECL package of imagemagick, which is called 'imagick'. Check out http://pecl.php.net/package/imagick for new versions.

wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz

Unzip/unpack the tgz file and change directory:

tar -xvzf imagick-3.1.0RC2.tgz
cd imagick-3.1.0RC2

The next step is to get information from the currently installed PHP version. All these informations will be gathered trough the program phpize. After this, the compilation is made:

phpize
./configure
make

Usually there would be a 'make install' at the end where the imagick extension would be copied to PHP's extension_dir but I prefer to set my own path.
So I created a new folder (/usr/local/imagick) and place the extension manually in there.

mkdir /usr/local/imagick
cp modules/imagick.so /usr/local/imagick/

Now the extension must be activated in PHP's configuration file php.ini. As I already have ioncube as extension loaded, I just place it below:

# grep "; Extensions" -A 7 /etc/apache2/php.ini
; Extensions

; IONCUBE
zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.3_ts.so

; ImageMagick
extension = /usr/local/imagick/imagick.so

Now just an Apache restart and the extension is active.

/etc/init.d/apache2 restart


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.