Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jmada/6bd3cb0ee75c598ecb6acd4793a31ed2 to your computer and use it in GitHub Desktop.
Save jmada/6bd3cb0ee75c598ecb6acd4793a31ed2 to your computer and use it in GitHub Desktop.
Linux Debian 11 Bullseye: How To Switch Between Multiple PHP Versions

Linux Debian 11 Bullseye: How To Switch Between Multiple PHP Versions

You need to first know what PHP version is running on your computer

php -v

Disable that version

sudo a2dismod php7.2

Enable the version you want to use

sudo a2enmod php5.6

Set the version you want as default

sudo update-alternatives --set php /usr/bin/php5.6

Alternatively to the last command, you can run the next one to set the default PHP version

sudo update-alternatives --config php

If you have installed other PHP extensions, set them as default as well

sudo update-alternatives --set phar /usr/bin/phar5.6

Finally, restart your Apache

sudo systemctl restart apache2

Check your default version

php -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment