Home > Documentation, English, php > Installing php-imagick on CentOS 5

Installing php-imagick on CentOS 5

For some reason I find myself having to work with CentOS a lot these days. I hate to say I hate something, but I can’t help saying I don’t like CentOS at all. Its packaging system is just so inconsistent and error prone I can’t understand how this could ever be considered an appropriate server platform for so many hosting companies. Why not use Debian? I don’t get it.

Anyway, installing the ImageMagick extension to PHP can be a challenge. Apparently, in some cases, you can easily get out of that problem issuing this series of commands as root (thanks to the author of this page for that):

yum install ImageMagick.i386
yum install ImageMagick-devel.i386
pecl install imagick

echo “extension=imagick.so” > /etc/php.d/imagick.ini
/etc/init.d/httpd restart

However, in my case I got a little error in the middle of the execution of pecl install imagick:

checking if ImageMagick version is at least 6.2.4… found version 6.2.8
checking for magick-wand.h header file… found in /usr/include/wand/magick-wand.h
checking PHP version is at least 5.1.3… /tmp/tmpi10iXi/imagick-3.0.0/configure: line 3339: test: Usage: /usr/bin/php-config [–prefix|–includes|–ldflags|–libs|–extension-dir|–include-dir|–php-binary|–version]: integer expression expected
configure: error: no. found 5.1.6
ERROR: `/tmp/tmpi10iXi/imagick-3.0.0/configure –with-imagick’ failed

So obviously, although I have PHP 5.1.6, this is not above 5.1.3… go figure.

The problem is complex, because you’re using PECL to download and install the package, and when it fails, PECL cleans its downloaded files, so you can’t directly take it from there (not without a little trickiness). In short, we’ll have to issue a CTRL+C in the middle of PECL’s execution, then go to /tmp/tmpSomething/ and hack the system. The commands below are not to be considered best practices. I am no system administrator nor am I very familiar with compilation nor the way PECL works (I have a good idea, but still).

Go to /tmp/tmpSomething (there shouldn’t be too many of these around)

cd imagick-3.0.0

vim configure

find the string 50103 (for some reason that’s how a version superior to 5.1.3 is looked for) around line 3339

Remove the if … condition (only leave the echo… result: yes. found line). Also remove the fi line. There should only be two lines eventually, both echoing “yes. found” in the middle

Save the file and exit



make install

echo “extension=imagick.so” > /etc/php.d/imagick.ini

/etc/init.d/httpd restart

And all that should make it…

Categories: Documentation, English, php Tags: ,
  1. Peter Bex
    October 31, 2010 at 11:57 am

    You shouldn’t blame CentOS for bad PECL packages.

    It looks like imagick 3.0.0 runs “php_config –vernum” which outputs a “usage” string because your php_config doesn’t know about that switch.

    It then ignores the faulty exit status and continues on by passing that error message string to test, interpreting it as a number and comparing it to 50103. This is broken behaviour in shells (or test(1) programs) which check their arguments strictly. See line 70 and 77 of http://svn.php.net/viewvc/pecl/imagick/tags/RELEASE_3_0_0/config.m4?revision=301415&view=markup

    This has since been fixed and the 3.0.1 RC2 does not contain this bug anymore.

    Why are you installing through pecl by the way? If you install the EPEL repository you can get a pre-packaged version of Imagick, so you don’t have to deal with installing from sources. See http://download.fedora.redhat.com/pub/epel/5/i386/repoview/php-pecl-imagick.html

    • Yannick Warnier
      October 31, 2010 at 12:08 pm

      Hi Peter,

      I must say I’m a bit upset to have to do any of that myself while I should just have a php5-imagick package, installed with one single apt-get install php5-imagick or something like that, no matter the version of PECL, PHP or the OS. I find it kind of Gentoo-like to have to hack the configure scripts. I never heard of the EPEL repository before (not worked much with CentOS), I’ll have a look at the next opportunity. Thanks!

      • Peter Bex
        October 31, 2010 at 12:37 pm

        Here is where the fact that CentOS is just RedHat repackaged comes in. RedHat only provides a handful of packages because they have to provide full commercial support on these packages.
        I think they consider it too big of a support burden to support all packages you could imagine, so they only provide those most popular packages found on “typical” server setups. For instance, GD, generally considered the “main” graphics lib for PHP _is_ supported by CentOS.

        EPEL and RPMForge are community efforts to add more packages to RedHat/Fedora (and, hence, CentOS). These packages are “community-supported”, which doesn’t matter with CentOS because the whole of CentOS is community-supported anyway ;)

        Basically, if you want to get any serious work done with CentOS you’ll need to install one of those third-party repositories.

        Another repository which I consider to be very useful because it generally has the latest up-to-date versions of PHP is the Utterramblings repository by Jason Litka (http://www.jasonlitka.com/yum-repository/)

        By the way, if you have to choose between EPEL and RPMForge, I can recommend going for EPEL. I’ve had some bad experiences with the quality of some of RPMForge’s packages but I’ve had better luck with EPEL.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: