pecl installs for previous php version

Rene Terstegen picture Rene Terstegen · Oct 24, 2013 · Viewed 28.4k times · Source

I've upgraded my MacBook to Mavericks and ruined my development environment. The problem I have right now is that my pear/pecl still tries to install for my previous (5.3) version of PHP instead of version 5.4.

PHP version:

$ php -v
PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

Pear

$ pear version
PEAR Version: 1.9.4
PHP Version: 5.4.17
Zend Engine Version: 2.4.0
Running on: Darwin MBP-retina.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64

If I install apc with

$ sudo pecl install apc
downloading APC-3.1.13.tgz ...
Starting to download APC-3.1.13.tgz (171,591 bytes)
.....................................done: 171,591 bytes
55 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
...
Build process completed successfully
Installing '/usr/local/Cellar/php53/5.3.26/include/php/ext/apc/apc_serializer.h'
Installing '/usr/local/Cellar/php53/5.3.26/lib/php/extensions/no-debug-non-zts-20090626/apc.so'
install ok: channel://pecl.php.net/APC-3.1.13
Extension apc enabled in php.ini

And enable the apc module in my php.ini php -v changes to this:

$ php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20100525/apc.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20100525/apc.so, 9): image not found in Unknown on line 0
PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

So pecl installs my apc extension in /usr/local/Cellar/php53/5.3.26/lib/php/extensions/no-debug-non-zts-20090626 and php expects it in /usr/lib/php/extensions/no-debug-non-zts-20100525/.

Simply making a symlink gives the following error:

$ php -v
PHP Warning:  PHP Startup: apc: 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
PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

So that's not a solution.

Can anybody point me in the right direction? I really don't have a clue what is going on here.

Answer

Layke picture Layke · Jan 2, 2014

In my case, I was attempting to install Gearman.

pecl install gearman would install it incorrectly.

php -i would show:

PHP Extension => 20100525

Yet pecl would install using:

PHP Api Version:         20090626

After changing my config settings to use:

First Fix

sudo pecl config-set php_ini /etc/php.ini
sudo pecl config-set php_bin /usr/bin/php5

I noticed that I would still get

WARNING: php_bin /usr/bin/php5 appears to have a suffix 5, but config variable php_suffix does not match

You can resolve this by using the config setting:

Additional Fix

sudo pear config-set php_suffix 5

Why was this a problem?

For me, I got into this problem because I added a custom PPA and reinstalled PHP. This meant that my previous install of php5-dev was out of sync.

You if you ever get into the same situation, you might just want to run..

apt-get remove php5-dev
pecl uninstall <extensionname>
apt-get install php5-dev
apt-get remove php5-pear
apt-get install php5-pear
pecl install <extensionname>

Alternatively, you can download the source and run phpize.