1. Install phpenv
Install phpenv
git clone https://github.com/madumlao/phpenv.git ~/.phpenv
Install php-build
to build php
git clone https://github.com/php-build/php-build.git ~/.phpenv/plugins/php-build
Add the following to .bash_profile
# phpenv
export PATH="/usr/local/opt/bison/bin:$PATH"
export PHPENV_ROOT="$HOME/.phpenv"
export PATH="$PHPENV_ROOT/bin:$PATH"
eval "$(phpenv init -)"
Load .bash_profile
in shell
source .bash_profile
2. How to Use phpenv ( Install and manage PHP )
How to check which version you can use.
phpenv install -l
How to check which version you insatlled.
phpenv versions
How to install the specified version of PHP.
phpenv install 7.4.8
Run this command after you install a new version of PHP
phpenv rehash
How to use the specified version of PHP at global.
phpenv global 7.4.8
How to use the specified version of PHP at local ( directory ).
phpenv local 7.4.8
This command will create .php-version
file at current directory.
3. How to use composer
Install composer to phpenv
git clone https://github.com/ngyuki/phpenv-composer.git ~/.phpenv/plugins/phpenv-composer
phpenv rehash
4. How to Update phpenv
cd $(phpenv root)
git pull
5. How to Update php-build
When a new version of PHP is released, you need to update php-build
. Otherwise you can not install the new version of PHP.
cd $(phpenv root)/plugins/php-build
git pull