How to Switch between Multiple PHP Version on Ubuntu

Tamrakar Shreyaa
1 min readAug 19, 2021

--

Switch From PHP 7.2 => PHP 7.4

Default PHP 7.2 is set on your system and you need to switch to PHP 7.4.

Apache:

$ sudo a2dismod php7.2
$ sudo a2enmod php7.4
$ sudo service apache2 restart

Command Line:

sudo update-alternatives --set php /usr/bin/php7.4
sudo update-alternatives --set phar /usr/bin/phar7.4
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4
sudo update-alternatives --set phpize /usr/bin/phpize7.4
sudo update-alternatives --set php-config /usr/bin/php-config7.4

Switch From PHP 7.4 => PHP 7.2

Default PHP 7.4 is set on your system and you need to switch to PHP 7.2.

Apache:

$ sudo a2dismod php7.4
$ sudo a2enmod php7.2
$ sudo service apache2 restart

Command Line:

sudo update-alternatives --set php /usr/bin/php7.2
sudo update-alternatives --set phar /usr/bin/phar7.2
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2
sudo update-alternatives --set phpize /usr/bin/phpize7.2
sudo update-alternatives --set php-config /usr/bin/php-config7.2

--

--

Tamrakar Shreyaa
Tamrakar Shreyaa

Written by Tamrakar Shreyaa

Laravel | PHP | Node| nestjs |API | AJAX | jQuery | Laravel vue | Livewire | LAMP stack | CI CD

No responses yet