'Installing pecl/imagick giving me module api compile errors

I've installed php 5.4.0, and went to re-install Imagick, from Pecl. When doing so everything works well, but when apache starts the following error is logged and the extension is not loaded as it should be:

PHP Warning:  PHP Startup: imagick: Unable to initialize module\
Module compiled with module API=20090626
PHP    compiled with module API=20100525
These options need to match in Unknown on line 0

For the life of me I can't understand where "20090626" is coming from. phpize -v shows:

Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525

And the same is printed when the pecl installation process starts. How do I correct this?



Solution 1:[1]

I had exactly the same problem as you when I compiled php from source. And had a previous php5-pear, php5-cli installed. I don't know why but I had to remove every single file still marked as "php5".

To find the files (should work on OSX too):

find / -name php5

Then just do rm -r /paths/that/are/listed/php5

When thats finished, just go into your bin folder of your new php installation and reinstall the mongo-driver with pecl. I had to do: sudo ./pecl uninstall mongo followed by sudo ./pecl install mongo

When the installation is finished, if you're using php-fpm dont forget do use sudo service php-fpm restart

Then it should work, check by typing (all this still in the php/bin folder):

sudo ./php -v

If you dont recieve any errors you should be good to go :)

//cubsink

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cantloginandidontknowwhy