How to change PHP version that drush runs under?

How to change PHP version that drush runs under?

Tue, 09/13/2016 - 11:27
Posted in:
0 comments

While adding new version of drush for Drupal you might have faced this error "Your command line PHP installation is too old. Drush requires at [error] least PHP {version}". In this article I will explain you how to set latest PHP vesion under drush.

What is the meaning of this error "Your command line PHP installation is too old. Drush requires at [error] least PHP {version}"? 

It means your Cpanel PHP version is older than drush require to run under. 

How to change or update version of PHP for drush?

Solution 1: You can contact your service provider and request for updation of Cpanel's PHP version. If they able to update php version then drush will work without any problems. But what if they not able to do this change? Then ask them to path to latest PHP version which will be useful in the second solution.

Solution 2: You should know path for latest php version for this solution.

Add an alias to .bash_profile or .bashrc  or .profile in your home directory. If you have already added an alias for drush during installation then please update that alias to.

alias drush='/path-to-php /path-to-drush'

Where path-to-php is:  The path to latest PHP version you want to run drush under. Note that drush needs PHP-CLI (command line interface) path.

and path-to-drush is: The path to drush in drush directory.

After adding this alias please try to run Drush if you are getting a new error something like this "Warning: require(__DIR__~/drush/includes/preflight.inc): failed to open stream: No such file or directory in /drush/drush.php" then they to seprate both alias.

alias drush='/path-to-drush' 
alias php='/path-to-php'

Done!

If you are still facing issues let me know in comments section. I will happy to assist you.

Tags

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
The content of this field is kept private and will not be shown publicly.