You are here: Home / Debian GNU/Linux / Servers / PHP / Install the Imagick PHP extension on Debian

Install the Imagick PHP extension on Debian

by Pierre-Yves Landuré last modified Dec 06, 2017 03:50

The Imagick extension add to PHP the power of ImageMagick image manipulation tool. One of its advantages is that it can read a lot more image formats than GD. This guide help you to install it on Debian.

This how-to is tested on:

  • Debian 6.0 Squeeze
  • Debian 7.0 Wheezy

Prerequisites

This how-to needs :

Installation from Debian repository

Install the software:

command apt-get -y install php5-imagick

Reload the configuration:

test -e '/etc/init.d/php5-fpm' && command service 'php5-fpm' 'restart'
test -e '/etc/init.d/apache2' && command service 'apache2' 'force-reload'

Manual installation

If the Debian package is not available, install the extension manually.

Detect PHP extension configuration path:

MODS_CONF_PATH='/etc/php5/conf.d'
test -d '/etc/php5/mods-available' \
  && MODS_CONF_PATH='/etc/php5/mods-available'

Environment preparation

Install the needed software:

command apt-get install php5-dev make php-pear imagemagick

Install the ImageMagick development libraries available on the system:

test -n "$(command apt-cache pkgnames 'libmagick9-dev')" && apt-get -y install 'libmagick9-dev'
test -n "$(command apt-cache pkgnames 'libmagickwand-dev')" && apt-get -y install 'libmagickwand-dev'

Update PEAR:

command pear channel-update pear.php.net
command pear upgrade PEAR

Update PECL:

command pecl channel-update pecl.php.net
command pecl upgrade

Software installation

Install the extension:

command pecl install imagick --with-apxs='/usr/bin/apxs2'

Enable the extension:

echo "; configuration for php IMagick module
; priority=20
extension=imagick.so" > "${MODS_CONF_PATH}/imagick.ini"
test -n "$(command -v php5enmod)" && command php5enmod 'imagick'

Reload the configuration:

test -e '/etc/init.d/php5-fpm' && command service 'php5-fpm' 'restart'
test -e '/etc/init.d/apache2' && command service 'apache2' 'force-reload'

Finalization

The manual installation recommends:

References

These books can help you:

Thanks