-1

I am running websites on my PC with following php5:

/etc/php5/apache2/php.ini

(this is what I can see when running phpinfo() command within website php code).

How to set Drush, so it would use the same php version?

I found this page which says, that I should detect, where is my bin/php file in my PC and set it in DRUSH_PHP environment variable. I have found following files:

./usr/bin/php

./usr/bin/php5

although, when I set this as DRUSH_PHP variable (in ~/.bashrc file), my drush would stop work at all. Otherwise, without this setting of variable, I can run drush commands, that does not need PHP to run.

Can anybody help, how to proceed, to set the same php version for drush as it is used by website in phpinfo()?

2

You can specify different PHP when running drush, e.g.

DRUSH_PHP=/path/to/php drush cr

In my configuration I've created the following symbolic (such as php71 and php72):

/usr/local/bin/php71 -> /usr/local/opt/php71/bin/php
/usr/local/bin/php72 -> /usr/local/opt/php72/bin/php

in the local bin/ folder which is in my PATH, so the commands are accessible.

Then I can run drush using different PHP version like:

DRUSH_PHP=php71 drush status

or:

DRUSH_PHP=php72 drush status

If you'd like to add DRUSH_PHP globally, add it to ~/.bashrc or ~/.bash_profile like:

export DRUSH_PHP=/full/path/to/php

Alternatively make sure your php path is in your PATH before any other versions.

To check whether you've multiple PHP version in your PATH, run this command:

which -a php
0

I spent half a day trying to re-install drush 8.x Finally stumbled on documentation for 7.x that fixed the 8.x problem.

Symptomatically, the PHP configuration came back blank. And as no surprise, DRUSH blew up when I attempted to run it within a Drupal instance.

 PHP configuration      :
 PHP OS                 :  Darwin
 Drush script           :  /usr/local/bin/drush
 Drush version          :  8.1.17
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :

The answer was found HERE

I am running MAMP with PHP 7.2.1. So the PATH should be as shown below. That fixed the problem - finally!

export PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php7.2.1/bin:$PATH

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.