Install ImageMagick – Ubuntu 16.04

Let’s start off with a freshly installed server running Ubuntu 16.04 (server).

This article assumes that you have Apache and PHP installed already.

Issue the following command at shell to install the base ImageMagick library:

sudo apt-get install imagemagick

The next step is to install the PHP library for ImageMagick, but you need to install a couple of pre-requisites for it:

sudo apt-get install gcc php-common

Now to install the imagick library:

sudo apt-get install php-imagick

Restart or reload apache:

service apache2 restart
OR
service apache2 reload

To verify that the imagick library has been added to php you have two options:

1) Issue the following command at shell to verify successful installation:

php -m | grep imagick

2) Drop a test.php file with the following content in the html directory (default: /var/www/html)

<?php
phpinfo();
?>

That’s it, you should be good.