Skip to content

Instantly share code, notes, and snippets.

@anhphamt
Last active December 14, 2016 16:19
Show Gist options
  • Save anhphamt/f807b20823fcae8aab3ef799ebdd78ca to your computer and use it in GitHub Desktop.
Save anhphamt/f807b20823fcae8aab3ef799ebdd78ca to your computer and use it in GitHub Desktop.
Installing Imagemagick anf Imagick extension OSX and CENTOS

Using MAC PORT to install Imagemagick

sudo port install ImageMagick

Install imagick php extension

sudo port install php70-imagick

To check if the imagick extension is installed, we can use this command:

php -r "print(class_exists('imagick'));"

Find the installed extension file: sudo find / -name "imagick.so" -print

Then copy it to extension folder of PHP.

Install MAC PORT

https://www.macports.org/

Download souce code

wget https://pecl.php.net/get/imagick-3.4.3RC1.tgz
tar xzfv imagick-3.4.3RC1.tgz
cd imagick-3.4.3RC1

Install ImageMagick-devel first.

yum install ImageMagick-devel

Build

phpize
 ./configure --with-php-config=/usr/bin/php-config 
make
make install

To know where php-config command, type:

which php-config

Copy imagick.so to extension directory.

If you do not know the path, find it out by (or change it in php.ini):

php -i | grep "extension_dir"

Then, edit php.ini, add extension=imagick.so.

If you run php in a webserver, restart the it, for example:

sudo service httpd restart

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment