PHP 7 to PHP 5.6 downgrade on Ubuntu 16.04

Hey there!!

Writing after quite some time. I forgot why I used to write and hence the blogs didn’t update. So here I go again!!

So, I recently did an upgrade from my good old Ubuntu 14.04 to Ubuntu 16.04 and as a web developer, I obviously have the LAMP stack installed in my system. So what happened during the upgrade was that my system updated php from 5.x to 7.0(not stable at the time of writing this post!) which is default in Ubuntu 16.04 (found this after quite some time of research!)

I had to downgrade due to some very special reasons. One of them might have been that my production server did not have the super efficient php7 engine and hence was running out of memory on a recursive function. I had to replicate the error on my local machine but with PHP7, I was not running out of memory (even with the same memory limitations. I am happy and sad at the same time now!!)

So I took the decision to downgrade.

I referred a few blogs and some stackoverflow for this. Please note that this worked for me and hence I wrote this blog.

I found this one the most useful,

Having read through all and following what she has done in the blog made me work out php5.6 just as I needed it to. A detailed tutorial indeed.
Since I had already had PHP7 with me, I did the following,

Added PPA to my setup

sudo add-apt-repository ppa:ondrej/php

Then update

sudo apt-get update


sudo apt-get install php5.6 php7.0

I now had both the versions installed into my machine. So I went on to my next step,

1. Disable PHP 7

sudo a2dismod php7.0

2. Enable PHP5.6

sudo a2enmod php5.6

3. Restart Apache

sudo service apache2 restart

Once this was done, however, my phpMyAdmin did not work, it was missing mbstring , so I went on to install mbstring extension like this

sudo apt-get install php5.6-mbstring
sudo apt-get install php5.6-mcrypt 

I still had to do this to make it work

sudo apt-get install php5.6-mysql 

After all this restart your apache2 and finally back to 5.x!! I did a lot of experimentations in between but this was what brought on the final output…I still do not have an entire overview of this(like most other people) but still it was an awesome experience and I learnt a lot out of this..


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s