Skip to content

Instantly share code, notes, and snippets.

@marcialsoto
Last active August 12, 2018 15:59
Show Gist options
  • Select an option

  • Save marcialsoto/ba22f546200d85838a9a7d0f1c89836c to your computer and use it in GitHub Desktop.

Select an option

Save marcialsoto/ba22f546200d85838a9a7d0f1c89836c to your computer and use it in GitHub Desktop.
nano /path/to/create-sh.sh
#!/bin/bash
chmod +x /path/to/create-sh.sh
mv /path/to/create-sh.sh /usr/local/bin/create-sh
# Switch PHP versions
sphp () {
local IS_PHP7=`php --version|grep "PHP 7.2"`
if [[ -z $IS_PHP7 ]]; then
echo "Switching to PHP 7.2"
sudo a2dismod php7.1
sudo a2enmod php7.2
sudo service apache2 restart
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
sudo service apache2 restart
php -v
else
echo "Switching to PHP 7.1"
sudo a2dismod php7.2
sudo a2enmod php7.1
sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php7.1
sudo update-alternatives --set phar /usr/bin/phar7.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.1
sudo update-alternatives --set phpize /usr/bin/phpize7.1
sudo update-alternatives --set php-config /usr/bin/php-config7.1
sudo service apache2 restart
php -v
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment