Install imagick on macOS Catalina + php 7.3

Girish
2 min readApr 22, 2020

Removed 7.3 old versions of php

brew install php@7.3
brew install imagemagick
pecl install imagick

Installing Pear

if pecl is not installed, install pear using below command

cd /tmpcurl -s -O https://pear.php.net/install-pear-nozlib.pharsudo php install-pear-nozlib.phar -d /usr/local/lib/php -b /usr/local/bin

If that fails

autoconf may be missing. To install it just use Homebrew. Once Homebrew is installed, installing autoconf is as simple as:

brew install autoconf

After autoconf is installed, try running the pear installer above again.

Upgrade PEAR

sudo pear channel-update pear.php.net

sudo pecl channel-update pecl.php.net

sudo pear upgrade-all --ignore-errors

Xcode Command Line Developer Tools

You will run into problems installing pecl extensions, if you don’t have the Xcode Command Line Extensions installed, so we’ll also install them.

xcode-select --install

Configuring PHP

Open /etc/php.ini and add .:/usr/local/lib/php/pear to include_path(if /etc/php.ini does not exist, create it with the following content).

include_path = ".:/usr/local/lib/php/pear"

Try again

pecl install imagick

Fixing broken directories error

Warning: mkdir(): File exists in System.php on line 294
PHP Warning: mkdir(): File exists in /usr/local/Cellar/php/7.3.3/share/php/pear/System.php on line 294
Warning: mkdir(): File exists in /usr/local/Cellar/php/7.3.3/share/php/pear/System.php on line 294
ERROR: failed to mkdir /usr/local/Cellar/php/7.3.3/pecl/20180731

You simply need to make the directory the script cannot, to accomplish this, run the following:

pecl config-get ext_dir | pbcopymkdir -p {paste clipboard value}

Try Again:
pecl install imagick

If you get the message

configuration option "php_ini" is not set to php.ini locationYou should add "extension=imagick.so" to php.ini

Find your php.ini file. you may use the below command

`sudo find /usr -name php.ini`

found in

/usr/local/etc/php/7.3/php.ini

open php.ini search for extension= and at the end of extension list add

extension=imagick.so

check if installed properly

php -r 'var_dump(Imagick::getVersion());'

References

--

--