3

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?

Simon
  • 61
  • 2
  • 8
  • look **[here](https://stackoverflow.com/questions/26584599/changing-pecl-installation-directory)**, one of the answers may be pertinent to your issue. – YvesLeBorg Jun 19 '18 at 09:49
  • 2
    Have a look here https://stackoverflow.com/a/50529784/2836621 – Mark Setchell Jun 19 '18 at 10:02
  • I've looked at `show-config` and changed all directories pointing to `/usr` to `/usr/local` but it doesn't seem to have helped anything. It's still trying to copy the header file to `/usr/include` – Simon Jun 19 '18 at 10:21
  • For a reference: I had the same issue running pecl install xdebug, got it unexpectedly fixed running the same command for the second time (without sudo both times). – Y. E. Aug 25 '18 at 12:29

1 Answers1

3

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.

Simon
  • 61
  • 2
  • 8