Run the below command and select the PHP version you want to switch to. In the below example, I’m switching the PHP version to 7.4.
Command Line: update-alternatives –config php
There are 4 choices for the alternative php (providing /usr/bin/php).
Selection Path Priority Status
- 0 /usr/bin/php8.0 80 auto mode
1 /usr/bin/php5.6 56 manual mode
2 /usr/bin/php7.0 70 manual mode
3 /usr/bin/php7.4 74 manual mode
4 /usr/bin/php8.0 80 manual mode
Press to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/bin/php7.4 to provide /usr/bin/php (php) in manual mode.
Note : But there is a problem in this; it will only change on the command line (CLI), but it won’t change in the browser.
Run the below commands to disable and enable multi PHP versions.
Commands :
a2dismod php7.4
a2enmod php8.1
Then Restart Ubuntu: systemctl restart apache2
Leave a Reply