Thursday, 30 August 2012

PHP5.4, Imagemagick & Pecl Installation

After upgrading to PHP 5.4.x, by using source compilation method, I realised our PHP was missing imagemagick extension.

ImageMagick is replacement for php's default GD library which WordPress uses for creating thumbnails on the fly. Using ImageMagick WordPress plugin, you can tell WordPress to use ImageMagick rather than PHP's default GD library. But for this to work your PHP must have ImageMagick extension enabled.

Installing & Enabling ImageMagick using Pecl

Installation is just 1-command job (usually)

pecl install imagick

But at the time of writing this post, when running above command against php5.4.x, installation will fail with following error:

/tmp/pear/temp/imagick/imagick_class.c:9534:2: error: 'struct _php_core_globals' has no member named 'safe_mode'

By default, pecl attempt to install stable build of imagick which as of today is not ready for PHP5.4. But they already have RC build here - http://pecl.php.net/package/imagick/3.1.0RC1

To force, pecl to install RC build, run following command:

pear config-set preferred_state beta

Now you can attempt installation again:

pecl install imagick

This time it should work! You will see output like below:

 Build process completed successfully   Installing '/opt/php5/lib/php/extensions/no-debug-non-zts-20100525/imagick.so'   Installing '/opt/php5/include/php/ext/imagick/php_imagick.h'   Installing '/opt/php5/include/php/ext/imagick/php_imagick_shared.h'   Installing '/opt/php5/include/php/ext/imagick/php_imagick_defs.h'   install ok: channel://pecl.php.net/imagick-3.1.0RC2   configuration option "php_ini" is not set to php.ini location   You should add "extension=imagick.so" to php.ini

As suggested by last line, do not forget to add extension=imagick.so in php.ini

-- This Post PHP5.4, Imagemagick & Pecl Installation is Published on Devils Workshop .





ifttt
Put the internet to work for you. via Personal Recipe 796541

No comments:

Post a Comment