Home / Tutorials / How to install Imagick on MacOS system
How to install Imagick on MacOS system cover

How to install Imagick on MacOS system

5 mins

13.1K

3 years ago

0 comments

Beginner

In this post, I assume that everyone has already installed PHP with Homebrew. if you have not done so, do run the command below.
brew install php

Check if Imagick is already installed


Before starting do check whether Imagick is already installed in the system.
php -m | grep imagick
If the response is blank that would mean Imagick is not installed.

Install Imagick dependency


The first thing to do is to install the necessary dependency for the setup. Do note that it will take some time to install the necessary dependency.
brew install pkg-config imagemagick

Install Imagick through PECL


Once that's done, run the command below to install Imagick using PECL command line.
pecl search imagick
pecl install imagick
brew services restart php

Update: 16/6/2021


If you are using macOS M1 and PHP version 7 or 8 and having some issues, do run the command below one at a time. Do specify your own PHP version below otherwise, it won't be able to symlink the file.
# install pcre2
brew install pcre2

# symlink the required file
ln -ln -s /opt/homebrew/Cellar/pcre2/10.37/include/pcre2.h /opt/homebrew/Cellar/php/8.0.6_1/include/php/ext/pcre
Install Imagick directly from the source, make sure to run the command one line at a time.
git clone https://github.com/Imagick/imagick

cd imagick

phpize && ./configure

make

make test

make install
Once it's installed, edit your php.ini file and add the line extension="imagick.so". Finally, restart your PHP with the command below.
brew services restart php

# or if using laravel valet
valet restart
By now you should have Imagick installed and you can test it by running the command above and get a response "imagick" in the terminal.
notion avatar

Ahmad Aziz

Week-end developer currently experimenting with web, mobile, and all things programming.

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Related Tutorials

Code Snippets

Collection of Laravel, AlpineJS, VueJS, Tailwind CSS, Flutter snippets and more. New snippets added every day.
View Snippets

Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your web projects
View Components

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this