There are different options to install/use PHP on Mac Leopard: use the default installation, use MacPort to install, or use XAMPP.
I like the all-in-one bundle XAMPP, it is easy to manage and includes most commonly used options. So, I use it for the most of the time. However, when I need to install imagick, a PHP wrapper for ImageMagick, I got into some troubles.
First, this package is not available via PEAR or PECL (PECL got into some errors). So, I end up manually compile imagick and copy the imagick.so into XAMPP extension directory. Here is what I did:
- change PATH to use default Leopard PHP installation, i.e. put /usr/bin ahead of XAMPP bin directory in PATH setting
- use MacPort to install ImageMagick (assume you have MacPort installed, Yahoo! it if you did not know how to)
- go to http://pecl.php.net/package/imagick, and find out the latest release
- manually build imagick and copy to XAMPP PHP extension directory (assuming using PHP5)
curl -O http://pecl.php.net/get/imagick-2.2.2RC1.tgz
tar xvfz imagick-2.2.2RC1
cd imagick-2.2.2RC1
phpize
./configure --with-imagick=/opt/local
make
sudo make install (we are using /usr/bin/php, so the imagick.so is created in /usr/lib/php/extensions/no-debug-non-zts-20060613/)
sudo cp /usr/lib/php/extensions/no-debug-non-zts-20060613/imagick.so /Applications/xampp/xamppfiles/lib/php/php5/extensions/no-debug-non-zts-20060613/imagick.so - edit /Applications/xampp/etc/php.ini, find “Dynamic Extensions” block, add
extension=imagick.so
6. testing, add this test.php file to /Applications/xampp/htdocs and try it at http://localhost/test.php, you will see this jpg turned 45 degree clockwise (get santa-claus.jpg from here)
< ?php
$img = new Imagick('santa-claus.jpg');
$img->rotateImage(’#fff’, 45);
header(’Content-type: image/jpeg’);
echo $img;
?>
Reference:
- Install PHP5, lighttpd and Imagick on Mac OSX Leopard (talks about using MacPorts to install these things)
- Mac with PHP / Imagick to install
- PECL::Package::imagick
- Install ImageMagick on Mac
- Compiling shared PECL extensions
No comments:
Post a Comment