Prevent extension version issues using PECL with multiple PHP installs

Simply calling phpize, config and make to compile a new extension, even if you point directly to your php binary can still compile with the wrong version as can installing via PECL, even if you reference the pecl binary directly. Using the peclcmd.php script, however, you should be able to get it to load the correct libraries and install in the right place.

For instance, I recently installed PHP 5.4 in /usr/local/php5 to use instead of the native Mac PHP 5.3 install (via but I wanted to leave the Mac PHP in place so now I have multiple versions of PHP and can use either one, which is great for dev but can cause compile issues.

On one machine I was eventually able to manually download the extension via pecl download and then phpize and install by passing: ./configure --with-php-config=/usr/local/php5/bin/php-config to the build config but wasn’t able to figure out how to do this directly via pecl. When I next tried the same update to another machine, I remembered the peclcmd file and was able to simply use a single command: /usr/local/php5/bin/php /usr/local/php5/lib/php/peclcmd.php install {extension-name} and done.

Ymmv :)

While I’m comfortable compiling from scratch, it definitely can save a lot of headaches to use a packager if it gives you what you need and make updates a lot easier.

Leave a Reply