In Part 1 of my MAMP + Lion series, I set up my MAMP installation so that I could use the included PECL installer. In this piece, I am going to explain how to install the php imagick extension. It’s going to be a little more work, but it builds on the foundation established in part one. Install MacPorts To begin, I followed the advice given by Mike Leo @ Unreal Expectations on installing imagick on snow leopard. Basically, in order to use the imagick extension, you need to install the ImageMagick libraries. I tried a few different routes, and came to agree with his assessment: use MacPorts. There are a few downsides to using MacPorts, but it mostly comes down to the fact that you have to install XCode 4.1, which is a time-consuming download. Fortunately, it’s free on the Mac App Store. After you install XCode, install the Lion MacPorts binary. Once you have MacPorts installed, you need to install ImageMagick. On my laptop, this took a long time, so be prepared to wait :). This is done simply in the terminal: $ sudo port install ImageMagick
Install PHP Imagick After the MacPorts library has finished installing, the rest of the process will be easier than it was with MAMP 1.X since MAMP 2 is no longer a universal binary. This means you don’t need to follow Mike’s installation process. Instead, the next step is to install using pecl, providing the Imagemagick prefix /opt/local when asked: $ pecl install imagick … Please provide the prefix of Imagemagick installation [autodetect] : /opt/local
Now just include the new extension in the php.ini file: echo “extension=imagick.so” >> /Applications/MAMP/bin/php/php5.3.6/conf/php.ini
From here, we need to update one of the MAMP dynamic libraries because it is too old. It’s pretty simple, but took me a while to figure out. Next time, I’ll make sure to look at the php-error logs when an extension doesn’t load! $ cp /opt/local/lib/libfreetype.6.dylib /Applications/MAMP/Library/lib/
Restart the Apache process and you should now have the Imagick library installed! Part 3 of this series will focus on enabling Xdebug!