Install Imagick extension for PHP 8 in macOS Big Sur
I am really grateful I’ve had a chance to have the Mac mini M1 on a new year 2021. It’s really fast, even I only use 8 gigs ram version! Also, the software that in my old mac no longer can use its latest update – like php with homebrew – is back! In this post, I will show you how to install imagick for PHP 8 in macOS Big Sur for it.
First, I assume that you already have Homebrew installed. Next is install PHP 8, we can use shivammathur/php for it, the installation steps are in its readme.
When PHP 8 installed, we can ensure that imagemagick already installed, if not, if we can install via Homebrew as well:
$ brew install imagemagick
Now, time to install imagick. There is no imagick release yet for php 8, but we can install the dev-master
already following this issue :
$ git clone https://github.com/Imagick/imagick $ cd imagick $ phpize && ./configure $ make $ sudo make install
When you run make
, if you got the following error:
/opt/homebrew/Cellar/php/8.0.0_1/include/php/ext/pcre/php_pcre.h:23:10: fatal error: 'pcre2.h' file not found
You can copy installed pcre2.h
from Homebrew:
cp /opt/homebrew/Cellar/pcre2/10.36/include/pcre2.h .
Next, you can re-run :
$ make $ sudo make install
After it installed, you can register imagick.so
to /opt/homebrew/etc/php/8.0/php.ini
:
extension="imagick.so"
Now, let’s check if it is installed:
➜ ~ php -a Interactive shell php > echo phpversion('imagick'); @PACKAGE_VERSION@
Yes, above @PACKAGE_VERSION@
should be just fine. That’s it!
I’m seeing a different error when trying to install the extension. I’m trying to install imagemagick for use with php7.3. I can get it to configure and build. but installing has the following error
mkdir: /usr/local/Cellar/php@7.3/7.3.28_1/pecl: File exists
mkdir: /usr/local/Cellar/php@7.3/7.3.28_1/pecl: No such file or directory
make: *** [install-modules] Error 1
cd into the folder above I can see pecl is a symlink to
admin 23 Jun 24 20:20 pecl -> /usr/local/lib/php/pecl
Any suggestion or recommendation?
I am not sure, it shows `/opt/homebrew/bin/pecl` in my local dev:
okay your symlink is different than mine. mine is pointing to:
/usr/local/Cellar/php@7.3/7.3.28_1/pecl -> /usr/local/lib/php/pecl
I wonder if I move pecl to another folder things will be different.
Hi following this up. following this thread here. https://github.com/Homebrew/homebrew-core/issues/41081. I was able to create the folder then after rerunning the sudo make install command able to install the extension. Thanks for this guide.
awesome