If you are a developer, something you need to install two different versions of PHP for testing or coding based on required platform. But install two parallel versions is not the easy task, we need some of support packages.
To install multiple versions of PHP, we need two packages
- phpenv: https://github.com/CHH/phpenv for setup separate rbenv environment.
- php-build: a utility for building versions of PHP to use them side by side with each other. ( https://github.com/chh/php-build )
First, we need install the phpenv
git clone [email protected]:CHH/phpenv.git cd phpenv bash bin/phpenv-install.sh
The
phpenv-install.sh
command sets up a separate rbenv environment for usage with PHP. This environment is stored in the
$HOME/.phpenv
directory and contains a
phpenv
executable which sets the
RBENV_ROOT
environment variable to
$HOME/.phpenv
.
Secondly, we install the php-build
git clone git://github.com/CHH/php-build.git cd php-build sudo bash install.sh
Finally, install other php version
sudo apt-get install libxml2-dev sudo apt-get install libcurl4-gnutls-dev sudo apt-get install libmcrypt4 libmcrypt-dev sudo apt-get install libreadline-dev sudo apt-get install libtidy-dev sudo apt-get install libxslt1-dev sudo php-build -i development 5.3.28 $HOME/.phpenv/versions/5.3.28 phpenv versions phpenv rehash phpenv global 5.4.9 php –version phpenv global system php –version