Home

Geeklog: What I Learnt Today / Adam

Building extensions with multiple versions of PHP

> Recently had to manually build a php extension for server running cpanel with multiple versions of PHP.
Did the regular
phpize, ./configure, make, make test, make
install
and then php wouldn't pick up the extension.
I got errors like
PHP Warning: PHP Startup: Unable to load dynamic library ...
imagick.so: undefined symbol: spl_ce_Countable)

Nice people at CWCS (https://www.cwcs.co.uk/) pointed out that I should have been using the cpanel version of PHP. Turns out I hadn't noticed that it had built itself against a very old version of PHP on the server rather than the version running on the command line.
The successful process looked like this

tar xzfv imagick-3.4.3.tgz
cd imagick-3.4.3
/opt/cpanel/ea-php72/root/usr/bin/phpize
./configure --with-php-config=/opt/cpanel/ea-php72/root/usr/bin/php-config
make
make test
make install

/ Adam