How to downgrade PHP7 to PHP5.x ?

php

Sometimes we had upgraded the PHP to 7.x version, but then only we know that some functionality won’t support in our web application / website, in that situation better switch back to the PHP 5.x version, It is not a much work, simply we could get back our php old version in few commands, will look it below,

If PHP 5.x version had been removed from your site, just install it with the following command

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0

Switch PHP version for Apache :

sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart

Switch PHP version for CLI :

sudo ln -sfn /usr/bin/php5.6 /etc/alternatives/php

That’s all ! from that, you server would be using old version of PHP.

Tags: