How to install PHP Imagick Extension on Centos7 with WHM/cPanel and EasyApache4

Imagick is a native php extension to create and modify images using the ImageMagick API.

ImageMagick is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF.

ImageMagick Studio LLC is a non-profit organization dedicated to making software imaging solutions freely available.

The Easy Way (if you’re lucky)

Enter your WHM panel if you have access to that, search for Module Installer from the Left Sidebar which is under the Software tab.

Choose PHP Pecl, wait a little then in the search box look for ‘Imagick’ – click Install, Done.

The Other Way (if you’re not lucky)

1 – Enter SSH mode (you need root privilege)

2 – Check which PHP version is running, type:

php -v

3 – Normally, you run pecl install Imagick from anywhere, but since we’re running cPanel with EasyApache4, php and its bin files will not be in their default place, please navigate to:

cd /opt/cpanel/ea-phpX/root/usr/bin

(replace X with your current php version, this should be a directory so you can list all using the command ls and then navigate to where the correct running php is)

4 – In this bin directory, You should find pecl (which is required to install the extension), type:

./pecl install Imagick

5 – Follow the instructions, Done.

Note that when you install Imagick you install it to the running php version, if you have multiple php versions and you need that Imagick running to every php version you have, you will need to install it to each one of them.

To check if you have it installed, you can either create a php file with phpinfo(); and run it, or you can run the command:

php -i | grep imagick

Using the shell command, You should get something similar to this:

imagick module => enabled
imagick module version => 3.4.3
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.skip_version_check => 0 => 0

If you don’t get any output or if you cannot see the Extension in the phpinfo file you created, then the extension did not get installed.