Compile PECL extension with phpize (multiple PHP versions)

- #PHP #PECL #Extension -

To compile a PECL extension with phpize we usually do:

$ cd extname
$ phpize
$ ./configure
$ make
# make install

But this could not work if you have multiple PHP installations on your Ubuntu server (i.e. 5.6, 7.0, 7.1).

To ensure the extension is installed only for a specific version you have to specify the correct version for the phpize and php-config binaries.

Example for version 7.0

$ cd extname
$ phpize7.0
$ ./configure --with-php-config=/usr/bin/php-config7.0
$ make
# make install

In this way the extension will be installed in the correct extension_dir folder.

Reference Links: