Installing ImageMagick PHP into MAMP Pro 2.0.5 OS 10.7 X Lion

So getting this to work can be quite tedious. It has taken hours upon hours and google search after google search but I have finally gotten it working.

The first things you need to do are

Once ImageMagick is installed on your system I am going to show you how to make it work with MAMP.

First you should run the following command

export PATH=/Applications/MAMP/bin/php/php5.3.6/bin:$PATH

This will make sure that we are using the correct PHP, Pear and PECL libraries. Then you will want to quite terminal and reopen it or you can type the following

source ~/.bash_profile

Second uncompress MAMPcomponents2.0.2.zip which is most likely in your downloads directory. Now to the commandline

cd ~/Downloads/MAMP_components_2.0.2

tar -xf php-5.3.6.tar.gz

mv php-5.3.6 /Applications/MAMP/bin/php/php5.3.6/include/php

cd /Applications/MAMP/bin/php/php5.3.6/include/php

Now durring my searches i came across someone setting config options but theres was for snow leopard so i modified it to work with Lion

MACOSX_DEPLOYMENT_TARGET=10.7 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"

export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET

One the build is done we can move on to building in the PECL extension for ImageMagick. Now because there is a bug with the latest version of the PECL extension for ImageMagick and installing it into MAMP, you will want to download versions 2.3 which you can get here. Once downloaded unzip and then do the following commands in the terminal

cd ~/Downloads/imagick-2.3.0/imagick-2.3.0

phpize

./configure

make

make install

Next edit /Applications/MAMP/Library/bin/envvars and change the following lines to like this

#DYLD_LIBRARY_PATH=”/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH”

#export DYLD_LIBRARY_PATH

Once that is done all you have to do is add

extension=imagick.so

to your php.ini file and restart MAMP. You should now have ImageMagick PHP installed and working properly. To make sure it is enabled you can view a page with the phpinfo() function in it.

Let me know if you have any questions and I hope this helps somebody.