CentOS 5.5 ImageMagick install + php module
- July 19th, 2010
- By jzerbe
- Write comment
Working this morning, I had to get ImageMagick working on a CentOS 5.5 VM. Pretty easy with YUM right? Well there were some complications installing the associated PHP module. So after doing the usual yum update, here is what you should do.
- yum install ImageMagick ImageMagick-devel
- If you are lucky “pecl install imagick” will work, if so skip to last 2 steps. If not continue along. I got the $PHP_AUTOCONF error.
- Head over to – http://pecl.php.net/package/imagick – and download the latest tarball (wget or whatever you fancy). At time of writing, I used “imagick-3.0.0RC2.tgz“.
- tar xzvf [da archive name] and cd into said archive
- gotta compile this thing from source: a)
phpizeb)./configurec)maked)make install(as root … duh!) [check out Steven's post on webhostingtalk.com] - load & restart: a)
echo "extension=imagick.so" > /etc/php.d/imagick.inib)/etc/init.d/httpd restart - check to see if it was installed:
php -m | grep imagick
Now let’s check to see if imagemagick “works”. Create a .php file on the server and access it with your web browser. Excerpted from docduke’s post on astahost.info.
<html> <head> <title>Test for ImageMagick</title> </head>
<body> <?
function alist ($array) { //This function prints a text array as an html list.
$alist = “<ul>”;
for ($i = 0; $i < sizeof($array); $i++) {
$alist .= “<li>$array[$i]“;
}
$alist .= “</ul>”;
return $alist;
}
exec(“convert -version”, $out, $rcode); //Try to get ImageMagick “convert” program version number.
echo “Version return code is $rcode <br>”; //Print the return code: 0 if OK, nonzero if error.
echo alist($out); //Print the output of “convert -version”
//Additional code discussed below goes here.
?> </body> </html>