how to switch default php version in linux ?

Created at: 2019-08-29 06:03:02 Updated at: 2019-08-29 06:08:39

in Linux

Problem :- How to switch default php version in linux ?

Platfom :- Linux

Solutions

Check which php versions are available with system

    sudo update-alternatives --config php

or else you can use following command to set each library

    sudo update-alternatives --set php /usr/bin/php7.2
    sudo update-alternatives --set phar /usr/bin/phar7.2
    sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2
    sudo update-alternatives --set phpize /usr/bin/phpize7.2
    sudo update-alternatives --set php-config /usr/bin/php-config7.2

Ff still not able to set the default version than look for the $PATH for more details and check weather this directory has conflicts with existing binary or not.

    cat $PATH