简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM