Tech

Can’t install imagemagick for PHP with pecl?

If you’re running WordPress on your own Mac OS X Server and have installed an updated version of PHP using Homebrew, you may have a directory mismatch that will prevent pecl from successfully installing imagemagick.

You will need to manually create the directory where imagemagick.so will be installed.

mkdir /usr/local/Cellar/php/7.4.7/pecl/yyyymmdd

where yyyymmdd is the version of imagemagick… which unfortunately you may not know until you run the install script and let it tell you which directory is missing.

$ brew install pkg-config imagemagick
$ pecl install imagick

You will get an Error message with the missing directory. Cut-and-paste into the mkdir argument. Once that directory is created, run pecl again.

$ pecl install imagick
[. . .]
install ok: channel://pecl.php.net/imagick-3.4.4
Extension imagick enabled in php.ini

Check that imagick is installed:

$ php -m | grep -i magic

You’ll get

imagick

Now restart the web server

sudo serveradmin stop web
sudo serveradmin start web

Now go look in your phpinfo.php (that you as a respectable admin have already created in a unlinked directory on your web server). A whole section for ImageMagick (imagick) should have been added. WordPress’s self-check should also show that it passed.