Imagick is a PHP extension that allows you to manipulate images. Some libraries or packages require that Imagick be installed on your server. However, because Imagick is optional, it’s not installed with PHP by default. Here’s how to install and enable Imagick on your Ubuntu server.


First thing, download and install Imagick. In Terminal, run the following commands. This will install Imagick for PHP 7:

$ sudo apt-get update
$ sudo apt-get install php-imagick

Verify that Imagick is now installed. This command should output the word imagick if it was installed successfully:

$ php -m | grep imagick

Find out the directory where your PHP extensions are installed. This command should output the path to that directory (example: /usr/lib/php/20190902, your path may be different):

$ php-config --extension-dir

Verify that the file exists in that directory:

$ ll /usr/lib/php/20190902

Edit php.ini

Now we need to edit the php.ini configuration file. To find out where this file is located, we need to look at the current php configuration. To do that, create a php info file that you can access from your browser. You may call it phpinfo.php:

// Filename: phpinfo.php
<?php phpinfo(); ?>

Load that file in your browser and look for the Loaded Configuration File setting. It should have the path to the php.ini file we need to edit (the path to your php.ini file may be different than what’s shown in this example):

Open that php.ini file:

$ sudo vi /etc/php/7.4/fpm/php.ini

Add the following line (you may add it at the end of the file) and save it:



If you’re doing this in your local development environment, restart your computer or virtual machine. If you’re doing this on an actual server, restart it. You may want to try restarting your web server only (apache, nginx, etc), but this may not work. It’s more effective to just do a restart on the machine so that all the changes take effect.

After restarting, verify that Imagick is available by loading your info.php file in your browser again, and this time you should see in it many references to the Imagick extension.