1. 安裝:ImageMagick:
命令:brew install ImageMagick
這種方式安裝下來的imageMagic,不缺少東西,報錯較少。安裝之后的位置:/usr/local/Cellar/imagemagick/
2. 安裝php擴展imagick
下載:wget https://pecl.php.net/get/imagick-3.4.3.tgz
解壓:sudo tar -zxvf imagick-3.4.3
安裝:
cd imagick-3.4.3 sudo /usr/bin/phpize export PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/7.0.8-12_1/lib/pkgconfig sudo ./configure --with-php-config=/usr/bin/php-config --with-imagick=/usr/local/Cellar/imagemagick/7.0.8-12_1 sudo make sudo make install
安裝環境的報錯
(1)pcre.h文件找不到
/usr/include/php/ext/pcre/php_pcre.h:29:10: fatal error: 'pcre.h' file not found #include "pcre.h" ^ 1 error generated. make: *** [swoole.lo] Error 1
解決方式:brew install pcre
(2)Operation not permitted, no-debug-non-zts
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20131226/ cp: /usr/lib/php/extensions/no-debug-non-zts-20131226/#INST@12567#: Operation not permitted make: *** [install-modules] Error 1
原因:
原來是OSX 10.11 El Capitan(或更高)新添加了一個新的安全機制叫系統完整性保護System Integrity Protection (SIP),所以對於目錄
/System
/sbin
/usr
不包含(/usr/local/)
僅僅供系統使用,其它用戶或者程序無法直接使用,而我們的/usr/lib/php/extensions/剛好在受保護范圍內
解決方式:禁掉SIP保護機制,步驟是:
重啟系統 按住Command + R (重新亮屏之后就開始按,象征地按幾秒再松開,出現蘋果標志,ok) 菜單“實用工具” ==>> “終端” ==>> 輸入csrutil disable;執行后會輸出:Successfully disabled System Integrity Protection. Please restart the machine for the changes to take effect. 再次重啟系統 禁止掉SIP后,就可以順利的安裝了,當然裝完了以后你可以重新打開SIP,方法同上,只是命令是csrutil enable
最后,在php.ini中加入擴展:
extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20160303" extension=imagick.so