Command to change PHP version in system and Apache2 with multiple PHP versions installed (from https://launchpad.net/~ondrej/+archive/ubuntu/php )
#!/bin/sh if [ -z "$1" ] then echo 'PHP version required' else if test -f "/usr/bin/php"$1; then sudo a2dismod php7.0 > /dev/null sudo a2dismod php7.1 > /dev/null sudo a2dismod php7.2 > /dev/null sudo a2dismod php7.3 > /dev/null sudo a2dismod php7.4 > /dev/null sudo a2enmod php$1 > /dev/null systemctl restart apache2 sudo ln -fs /usr/bin/php$1 /etc/alternatives/php sudo ln -fs /usr/bin/php-config$1 /etc/alternatives/php-config sudo ln -fs /usr/bin/phpdbg$1 /etc/alternatives/phpdbg sudo ln -fs /usr/bin/phpize$1 /etc/alternatives/phpize sudo ln -fs /usr/bin/phar$1 /etc/alternatives/phar sudo ln -fs /usr/bin/phar.phar$1 /etc/alternatives/phar.phar echo 'Changed PHP version to: '$1 else echo 'Wrong PHP version: '$1 fi fi