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) vers
None of the other answers (as yet) seem to address having multiple "co-installable" PHP versions while wanting to build a given extension for all installed PHP versions.
To illustrate the scenario in which I find myself (I'm using the Ondrej Surý PHP PPAs for Ubuntu 16.04 LTS):
root@localhost:~# ls -lah /usr/bin/*php*
-rwxr-xr-x 1 root root 11K Apr 19 12:50 dh_php
-rwxr-xr-x 1 root root 3.1K Apr 5 2016 dh_phpcomposer
-rwxr-xr-x 1 root root 5.4K Apr 5 2016 dh_phppear
lrwxrwxrwx 1 root root 21 Jul 24 00:44 php -> /etc/alternatives/php
-rwxr-xr-x 1 root root 4.3M Jul 6 10:04 php5.6
-rwxr-xr-x 1 root root 4.3M Jul 6 10:04 php7.0
-rwxr-xr-x 1 root root 4.4M Aug 4 14:22 php7.1
lrwxrwxrwx 1 root root 28 Jul 24 00:44 php-config -> /etc/alternatives/php-config
-rwxr-xr-x 1 root root 4.3K Jul 6 10:03 php-config5.6
-rwxr-xr-x 1 root root 4.1K Jul 6 10:03 php-config7.0
-rwxr-xr-x 1 root root 4.1K Aug 4 14:21 php-config7.1
lrwxrwxrwx 1 root root 24 Jul 24 00:44 phpize -> /etc/alternatives/phpize
-rwxr-xr-x 1 root root 4.7K Jul 6 10:03 phpize5.6
-rwxr-xr-x 1 root root 4.6K Jul 6 10:03 phpize7.0
-rwxr-xr-x 1 root root 4.6K Aug 4 14:21 phpize7.1
pecl install extension-name
does the job for PHP 7.1, but not the others.
The other anwsers indicate that while it's possible to uninstall/reinstall php*-dev
, I'd much rather not, given the intentional, co-installed PHP versions on the system.
One solution is to build the extension for each version present on the system.
This snippet demonstrates building with PHP 5.6, but I've done the same for 7.0 and 7.1 and the steps are the same.
This example demonstrates cloning the extension from a Git repository, but one may use any source directory.
(#
indicates that you must be root or use sudo
)
# apt-get install php-dev
# cd ~
# git clone https://github.com/vendor/extension-name
# cd ./extension-name
# phpize5.6
# ./configure --with-php-config=/usr/bin/php-config5.6
# make clean
# make
# make install
# ln -s /etc/php/5.6/mods-available/extension-name.ini /etc/php/5.6/fpm/conf.d/20-extension-name.ini
# service php5.6-fpm reload