Switch PHP Versions on Ubuntu | How can I downgrade from PHP 7 to PHP 5.6 on Ubuntu 16.04? | How to install PHP on Ubuntu?

We often work on multiple projects and there might be possibility the you are working on a project which has been developed in latest PHP version and another project has been developed in older PHP version.

I faced the same challenge in my projects and here in this article I'll explain the installation of PHP version 7.0 and 5.6.

We also will be upgrading and downgrading PHP versions. We will not uninstall and PHP version we will keep both versions of PHP but we will switch PHP version according to our need.

First of all here are some commands to install the PHP.

To install PHP 5.6

To install PHP 7.0

Restart server:

Switching PHP versions:

From php5.6 to php7.0:



From php7.0 to php5.6:




Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *