Install imagemagick as PHP extension in Debian without apt

Written by - 1 comments

Published on - 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 for new versions.


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:


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/ /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

zend_extension = /usr/local/ioncube/

; ImageMagick
extension = /usr/local/imagick/

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)

Ă€ngel from wrote on Mar 18th, 2021:

Thank you very much, it's help me.