简体   繁体   English

在Mac上通过PECL安装PHP imagick

[英]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. 我正试图在装有High Sierra 10.13.5的Mac上安装php imagick扩展程序。

I have PHP 7.2 installed through brew and PEAR 1.10.5 installed. 我通过brew和PEAR 1.10.5安装了PHP 7.2。 When trying to install imagick using sudo pecl install imagick I get: 当试图使用sudo pecl install imagick我得到:

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. 看起来我正在使用安装目录应位于/usr/local的Mac权限,但我无法弄清楚如何更改它。 Any ideas how to fix this? 任何想法如何解决这一问题?

In the end I needed PHP 7.1 not 7.2 but I still had the same problem. 最后我需要PHP 7.1而不是7.2但我仍然有同样的问题。

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 从运行php-config获取当前的php扩展目录
  • 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 将该目录中的所有内容(在我的情况下为/usr/lib/php/extensions/no-debug-non-zts-20160303)/usr/local的等效项,所以在我的情况下/usr/lib/php/extensions/no-debug-non-zts-20160303)/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 更新php.ini并将extensions_dir设置为/usr/local的新目录
  • Go to the build directory from pecl error and find the imagick tgz 从pecl错误转到build目录并找到imagick tgz
  • Extract this and enter the created directory 解压缩并输入创建的目录
  • As root: 作为根:
    • run ./phpize 运行./phpize
    • run ./configure 运行./configure
    • run make 跑去make
    • Edit the makefile and change the include directory to the /usr/local equivalent. 编辑makefile并将include目录更改为/usr/local等效项。
    • run make install 运行make install
  • Edit the php.ini and add imagick.so to the extensions section 编辑php.ini并将imagick.so添加到扩展部分

It seems to be working for me now but this probably isn't the easiest way to go about getting it installed. 它现在似乎对我有用,但这可能不是安装它的最简单方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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