Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I downgrade or use PHP 7.2 without uninstalling PHP 7.4? Is it possible to use PHP 7.2 as default instead of the latest version?

I am using linux Ubuntu 18.04 And I wanna revert back to the previous version of PHP.

I've seen tutorials that requires me to uninstall the latest version, now I am asking if there is a workaround in this problem such that I can easily switch from using 7.2 or 7.4.

like image 460
pauxplorer Avatar asked Jan 17 '20 06:01

pauxplorer


People also ask

Can I downgrade my PHP version?

If you'd like to downgrade your PHP installation you can do so without interfering with the path to your installation and can simply overwrite older files. This process will overwrite your current PHP.

How do I remove a specific version of PHP?

Select Updates. Select Add/ Remove Components. Select Web Hosting >> PHP interpreter versions. Select the outdated version of PHP, and then select Remove.


2 Answers

I have faced the same problem and Here is the solution:

sudo update-alternatives --config php

Now select which version U want on right now, thanks

like image 104
Hadisur Rahman Avatar answered Oct 23 '22 18:10

Hadisur Rahman


Downgrade from 7.4 to 7.2

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

sudo apt-get install php7.2

sudo apt-get install php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-mysql php7.2-mbstring  php7.2-zip php7.2-fpm php7.2-intl php7.2-simplexml

   

sudo a2dismod php7.4

sudo a2enmod php7.2

sudo service apache2 restart

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
like image 35
Ayman Elshehawy Avatar answered Oct 23 '22 18:10

Ayman Elshehawy