PHP Version Manager (PHPENV)

With the recently release PHP 5.6, I stumbled upon these tools, phpenv, (inspired by rbenv) and php-build which let you build different PHP versions without messing up your existing installation. For installation steps, we're following Kobito's setup guide.

1. To setup both phpenv and php-build, just type these commands. Be extra careful when running downloaded shell script directly from the net.

$ curl | bash
$ git clone git:// ~/.phpenv/plugins/php-build
$ echo 'export PATH="$HOME/.phpenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(phpenv init -)"' >> ~/.bashrc
$ exec $SHELL -l

2. Checking our installation. Second command should give you a long list of PHP versions.
$ phpenv --version
rbenv 0.4.0-98-g13a474c

$ phpenv install -l

3. As I was running Debian, install all the necessary packages so we can compile the source code.
$ sudo apt-get install make ccache re2c libcurl libcurl-dev bison libcurl4-gnutls-dev libjpeg62-dev libmcrypt-dev libtidy libtidy-dev libxslt1-dev apache2-prefork-dev

4. Compilation. Took me around 15 minutes.
$ CFLAGS="-g" phpenv install 5.6.0

$ which php

5. Switching between installed version (system) and your compiled version.
$ phpenv versions
* system (set by /home/kianmeng/.phpenv/version)

$ phpenv global

$ php --version | grep ^PHP
PHP 5.4.4-14+deb7u14 (cli) (built: Aug 21 2014 08:36:44)

$ phpenv rehash
$ phpenv global 5.6.0

$ phpenv global

$ php --version | grep ^PHP
PHP 5.6.0 (cli) (built: Sep  1 2014 03:26:46)

Unfortunately, to install phpdbg, you'll need to create another shell script, as a plugin to php-build in order to build it. Someday perhaps.

No comments:

Post a Comment