Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

change php version in linux

vim ~/.bashrc
alias phpchange=change_php

change_php(){
        CURRENT_PHP_VERSION=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d"." 2>/dev/null)
        echo "Current PHP Version is ".$CURRENT_PHP_VERSION;
        sudo a2dismod php$CURRENT_PHP_VERSION;
        sudo a2enmod php$1;
        sudo update-alternatives --set php /usr/bin/php$1
        sudo service apache2 restart

}


and then run phpchange 7.0 // to switch to 7
make sure you need to have that version installed
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #change #php #version #linux
ADD COMMENT
Topic
Name
6+8 =