Friday, October 23, 2009

ImageMagick, CentOS, and PHP

Ever wonder how to get ImageMagick to work well in a PHP environment on CentOS?

I have done it a few times, and here's a simple recipe to follow. I use this recipe when I have yum managing the basic libraries, but not managing the libraries in active use on the site (like php, apache, perl, imagemagick and a few others).
% sudo yum install libX11-devel
% sudo yum install libjpeg libjpeg-devel
% sudo yum install libpng libpng-devel
% sudo yum install libtiff libtiff-devel
% # download ImageMagick from
% ./configure --with-perl=/usr/local/bin/perl
% make
% sudo make install
(make sure that /usr/local/lib is in the /etc/*.conf files)
% sudo /sbin/ldconfig

Now image-magick is installed.

To Use in PHP
% sudo /usr/local/bin/pecl install imagick
% sudo vi /usr/local/lib/php.ini
% sudo /etc/init.d/httpd stop
And that's it. Hope this helps.

No comments: