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? 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? linux linux

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 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


Yes, you can.

1- To stop running PHP 7.4, run the commands below to disable it for Apache2:

sudo a2dismod php7.4

2- Then run the commands below to enable PHP 7.2 for Apache2 to use:

sudo a2enmod php7.2

3- Restart Apache2 for the changes to apply by running the commands below:

sudo systemctl restart apache2.service


Downgrade from 7.4 to 7.2

sudo add-apt-repository ppa:ondrej/phpsudo apt-get updatesudo apt-get install php7.2sudo 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.4sudo a2enmod php7.2sudo service apache2 restartsudo update-alternatives --set php /usr/bin/php7.2sudo update-alternatives --set phar /usr/bin/phar7.2sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2sudo update-alternatives --set phpize /usr/bin/phpize7.2sudo update-alternatives --set php-config /usr/bin/php-config7.2