PHP Version not correct in SSH

7 posts / 0 new
Last post
#1 Sat, 06/08/2019 - 07:59
cs10

PHP Version not correct in SSH

Hi there. I have a Virtual Server and I have set the PHP version to PHP 7.2 (via Server Configuration -> PHP Version).

Its a Wordpress site, and when I log into the admin area, this shows correctly as using PHP 7.2.

However, when I log in via SSH, and run PHP-V, the version returned is 5.4.16.

This means I can't use the WP CLI. When I try to, I get the following:

Your server is running PHP version 5.4.16 but WordPress 5.2.1 requires at least 5.6.20.

Can anyone help please?

Thanks, Craig

Sat, 06/08/2019 - 08:33
andreychek

Howdy,

The default PHP version on CentOS is indeed PHP 5.4... however, if there's additional PHP versions installed, you can call them if you know the correct path.

To see the path of all the PHP versions installed, you can go into System Settings -> Re-Check Config, and it'll show you the path of all the PHP versions it detects.

-Eric

Sat, 06/08/2019 - 09:48
cs10

Hi Eric, Thanks for the reply.

I have done that now, and it has detected the new ones I've added.

The following PHP versions are available : 5.4.16 (/bin/php-cgi), 5.6.25 (/opt/rh/rh-php56/root/usr/bin/php-cgi), 7.0.27 (/opt/rh/rh-php70/root/usr/bin/php-cgi), 7.1.8 (/opt/rh/rh-php71/root/usr/bin/php-cgi), 7.2.10 (/opt/rh/rh-php72/root/usr/bin/php-cgi), 5.4 (mod_php)

No PHP-FPM packages were found on this system.

PHP versions have changed to 5, 5.4, 5.6, 7.0, 7.1, 7.2 since last check. Regenerating any missing php.ini files

What should I do now?

Thanks, Craig

Sat, 06/08/2019 - 09:54
andreychek

The output there shows you the paths for all the additional PHP versions you have installed... so you can use those paths to get your desired PHP rather than using the default "php", which is only PHP 5.4.

-Eric

Sat, 06/08/2019 - 10:14
cs10

Sorry I'm a bit lost.

I've already set the php version against the virtual server.

Is just when I use wp cli via ssh.

How do I sort this? Thanks for the reply by the way, really appreciate it

Sat, 06/08/2019 - 10:20
andreychek

You'll need to configure your wp-cli binary to use your preferred PHP version.

I'm not personally familiar with how to do that, but I see some examples here:

https://wordpress.stackexchange.com/questions/244164/wp-cli-selecting-ph...

Sat, 06/08/2019 - 12:27
cs10

I'll give it a go to see if I can follow it.

Failing that, is there no way to set the default to a later version?