Created
April 8, 2022 08:40
-
-
Save jakubenglicky/a07053c2fe0c187f0bde860ca08ff60b to your computer and use it in GitHub Desktop.
Easy switch between PHP versions
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 | |
NEED=$1 | |
CURRENT=$(php -r "echo explode('.', PHP_VERSION)[0] . '.' . explode('.', PHP_VERSION)[1];") | |
echo "Switching from PHP$CURRENT to PHP$NEED" | |
sudo a2dismod php$CURRENT | |
sudo a2enmod php$NEED | |
sudo service apache2 restart | |
echo "Apache ... OK" | |
sudo update-alternatives --set php /usr/bin/php$NEED | |
echo "CLI ... OK" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment