Linux change php Version
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
Ubuntu/Debian
Check installed PHP versions: php -v and ls /usr/bin/php*
Install desired PHP version: sudo apt-get install php<version> (e.g., php8.1)
Update PHP cli: sudo update-alternatives --set php /usr/bin/php<version>
Update PHP for Apache (if using): sudo a2enmod php<version> and sudo service apache2 restart