Running php 7.x from command line on CentOS 7

Submitted by daniel on Mon, 14/12/2020 - 17:33

On a web server running on top of CentOS 7, the default version of PHP is still stuck on php 5.4.x

php -v
PHP 5.4.16 (cli) (built: Apr  1 2020 04:07:17) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.0.3, Copyright (c) 2002-2017, by ionCube Ltd.

This is in part because CentOS is forked from RHEL 7. Interestingly despite PHP support for older versions of php being dropped by PHP themselves, RHEL will still provide support up until 2024!

Typically your front facing web-server will typically run a later version of php. Most modern control panels also make it easy for you to switch between different versions of php, and typically have multiple versions installed simultaneously. This is the case with Plesk Obsidian. Here we look at how you can easily run a different version of php depending on your requirement. e.g. if  running the latest version of Drush with say Drupal 9 will likely require at least php 7.3

If you know the path of php you can use like this without having to modify your path settings. Typically php on plesk is stored in /opt/plesk/php/[version] so something like this should get you started.

/opt/plesk/php/7.3/bin/php  /path/to/project/vendor/bin/drush updb

 

Add new comment