Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change php-cli version on Ubuntu 14.04?

Tags:

linux

php

ubuntu

I am new to using Linux and I broke some php settings while tampering.

If I execute a php script containing: phpinfo(); it shows the php versions as 5.6, but via the command line, if I run php -v it returns a version of 7.0.

I want to have both versions match.
How can i fix my command line PATH to also use php 5.6?

like image 490
Alihan Koç Avatar asked Mar 27 '17 07:03

Alihan Koç


People also ask

How do I enable a specific version of PHP in Ubuntu?

You can do sudo update-alternatives --config php to set which system wide version of PHP you want to use. This makes your command line and apache versions work the same. You can read more about update-alternatives on the man page.

How do I find my default PHP version Ubuntu?

Open a bash shell terminal and use the command “php –version” or “php -v” to get the version of PHP installed on the system. As you can see from both the command output above, the system has PHP 5.4. 16 installed.


1 Answers

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

Please see: Source

like image 171
Sergey Repin Avatar answered Oct 06 '22 10:10

Sergey Repin