Install ImageMagick on a cPanel Server

image-magick

If you are running a cPanel server, you may be aware they recently removed their ImageMagick installation script. This now means that to install ImageMagick on a cPanel server, you must either use yum or perform a manual installation. The CentOS 6.x repositories are much more current than they used to be, so it is now a relatively painless task to install ImageMagick on a cPanel server. At the time of writing, the version available to CentOS 6 was 6.5.4 (Dec 2012).

 

Install ImageMagick on a cPanel Server Using YUM

This is by far the easiest way to get a reasonably current version of ImageMagick installed on your server ready for use by your web applications. The advantage of using this method is that it can then be updated easily via yum when new versions are made available in CentOS repositories.

To install ImageMagick on a cPanel server using yum, just enter the following:

yum -y install ImageMagick-devel ImageMagick-c++-devel

If additional dependencies are required, these will all be listed along with the version of ImageMagick that is about to be installed. When prompted to install, just type Y and hit enter.

NOTE: for ImageMagick to work with your web applications, you also need to install imagick. See “Bind ImageMagick Into PHP using Imagick” below.

 

Manually Install ImageMagick on a cPanel Server

If you absolutely must have the latest version, then a manual installation is required, unless you want to consider installing some third-party repositories. To do this, follow the steps below

1. Login to your server via SSH as root and download the latest version:

wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz

2. Unpack the downloaded files

tar xvfz ImageMagick.tar.gz

3. Configure and compile the installation files:

To first check the version number that was installed, just enter ls at the command prompt and you will see the folder with appropriate version number in its name.

cd ImageMagick-6.8.6-7
./configure
make

4. As long as ImageMagick compiled without any errors, install it onto your system:

make install

5. For a quick  check that ImageMagick is installed and running correctly, enter the following:

/usr/local/bin/convert logo: logo.gif

6. For a more advanced check on your ImageMagick installation, run the command below which will perform a full test on the installation and should result in a “all tests passed”.

make check

Bind ImageMagick into PHP using Imagick

For your new ImageMagick installation to work with your web php scripts, you now need to bind it into PHP. To do this using Imagick, just follow the steps below.

  1. Login to WHM and navigate to the “Module Installers” option under “Software” in the left hand menu
  2. On the following page, select the “Manage” link beside the PHP Pecl language option
  3. Enter imagick into the “Install a PHP Pecl” field and then click the install button.

Test Your Installation

All things going well, you should now have a running installation of ImageMagick. The best way to test this is to install one of the many free PHP gallery applications (e.g. Gallery 3, Coppermine) and configure the application to use ImageMagick. If all is working as it should be, these applications should enable this feature with no complaint and the gallery should function correctly on the front end.