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:
Verify that Imagick is now installed. This command should output the word
imagick if it was installed successfully:
Find out the directory where your PHP extensions are installed. This command should output the path to that directory (example:
/usr/lib/php/20170718, your path may be different):
Verify that the file
imagick.so exists in that directory:
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
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):
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.