Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing PHP imagick through PECL on Mac

I'm trying to get the php imagick extension installed on a Mac with High Sierra 10.13.5.

I have PHP 7.2 installed through brew and PEAR 1.10.5 installed. When trying to install imagick using sudo pecl install imagick I get:

Build process completed successfully
Installing '/usr/include/php/ext/imagick/php_imagick_shared.h'
ERROR: failed to mkdir /usr/include/php/ext/imagick

It looks like I'm hitting the Mac permissions where the install directory should be in /usr/local but I cant figure out how to change it. Any ideas how to fix this?

like image 856
Simon Avatar asked Aug 04 '26 04:08

Simon


1 Answers

In the end I needed PHP 7.1 not 7.2 but I still had the same problem.

Not sure if all of the steps I took were necessary but here's how I got around it:

  • Get the current php extensions directory from running php-config
  • Copy everything from that directory (in my case /usr/lib/php/extensions/no-debug-non-zts-20160303) to the equivalent in /usr/local so in my case to /usr/local/lib/php/extensions/no-debug-non-zts-20160303
  • Update the php.ini and set the extensions_dir to the new directory in /usr/local
  • Go to the build directory from pecl error and find the imagick tgz
  • Extract this and enter the created directory
  • As root:
    • run ./phpize
    • run ./configure
    • run make
    • Edit the makefile and change the include directory to the /usr/local equivalent.
    • run make install
  • Edit the php.ini and add imagick.so to the extensions section

It seems to be working for me now but this probably isn't the easiest way to go about getting it installed.

like image 88
Simon Avatar answered Aug 05 '26 18:08

Simon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!