Linux

How to Switch PHP versions using Command Line in Ubuntu

How to Switch PHP versions using Command Line in Ubuntu

Hello Folks, Today I started new tutorial category which is linux tutorial. In this tutorial, Today I will explain to about how to switch PHP versions using command line in Ubuntu. On your system, you may have installed multiple versions of PHP.

For example, in your system there are PHP 5.6 and PHP 7.2 both versions are already installed. Now, By default there are 7.2 version enabled in your system. But, when you want to switch in PHP 5.6 version then, how to switch to other version?

Let’s follow the below steps to how to switch PHP versions using command line in Ubuntu :

1) First of all, Disable PHP version using this below command :

Using this above command you can disable specific PHP version.

2) Then, Enable PHP version using this below command :

Using this above command you can enable specific PHP version.

3) Next, Set PHP 5.6 as default PHP version :

sudo update-alternatives --set php /usr/bin/php5.6

4) In Last, Restart Apache server :

sudo service apache2 restart

Now, you can check your PHP version using below command execute :

You can execute these all commands from any directory location in terminal.

That’s it !!!

I hope this blog is easy to understand about how to switch PHP versions using command line in Ubuntu. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution.

Keep liking and sharing 🙂

Tagged , ,