Last active
September 23, 2020 05:06
-
-
Save qa1/d4892d13ecfb886d706112f2bc9514d1 to your computer and use it in GitHub Desktop.
This command will change your php version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
phpversion=$1 | |
[ -z "$phpversion" ] && { echo "Please input php version. for example: 7.0"; exit 1;} | |
phpextdir=$(php -r "echo ini_get('extension_dir');") | |
[ ! -f "/usr/bin/php$phpversion" ] && { echo "PHP version $phpversion not found! /usr/bin/php$phpversion"; exit 1;} | |
sudo update-alternatives --set php /usr/bin/php$phpversion && | |
sudo update-alternatives --set phar /usr/bin/phar$phpversion && | |
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$phpversion && | |
sudo update-alternatives --set phpize /usr/bin/phpize$phpversion && | |
sudo update-alternatives --set php-config /usr/bin/php-config$phpversion && | |
sudo pecl config-set php_ini /etc/php/$phpversion/cli/php.ini && | |
sudo pecl config-set ext_dir $phpextdir && | |
sudo pecl config-set bin_dir /usr/bin/ && | |
sudo pecl config-set php_bin /usr/bin/php$phpversion && | |
sudo pecl config-set php_suffix $phpversion | |
echo "Switch PHP to version $phpversion" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment