0

I have a relatively fresh instance of Ubuntu 16.04 running a Drupal 7 site, with php5.6 installed instead of php7. The drupal site runs well. I am trying to get drush installed so that I can easily do updates.

I have done the global install per http://docs.drush.org/en/8.x/install/

Specifically, as the ubuntu user (no root login)

wget http://files.drush.org/drush.phar

/usr/bin/php5.6 drush.phar core-status

PHP configuration : /etc/php/5.6/cli/php.ini PHP OS : Linux
Drush script : /home/ubuntu/drush.phar
Drush version : 8.1.12
Drush temp directory : /tmp
Drush configuration :
Drush alias files :

chmod +x drush.phar

sudo mv drush.phar /usr/bin/drush

/usr/bin/php5.6 drush --version

Could not open input file: drush

What am I missing?

  • What does which drush output? If it outputs /usr/bin/drush, then check drush is readable. – kiamlaluno Jul 12 '17 at 23:28
  • $ which drush /usr/bin/drush – Rob Brandt Jul 12 '17 at 23:36
  • Drush is standalone, just use drush --version – Clive Jul 13 '17 at 6:48
  • Thanks. That leads me back to an earlier problem. When I try to use it without specifying a php version, I get an error: PHP Fatal error: Uncaught Error: Call to undefined function cache_get() in /home/crm/domains/testing.crm.botany.org/public_html/includes/module.inc:754 I googled this, and found references to this being a problem when running under php7. Thus, I was trying to force it to use the 5.6 binary. Other solutions for this problem included drush not finding the settings.php file (I am in the right directory and the file permissions are OK), and specifying 127.0.0.1 for host – Rob Brandt Jul 13 '17 at 16:37
0

The only way I have found to fix this problem is to change the default php used by the server. In other words, /usr/bin/php was originally a symlink to /usr/bin/php7.1, and changing it to a symlink to /usr/bin/php5.6 solved the problem.

But it appears that drush will always use the default php even if you install it with an alternative.

0

The error you are getting when you run /usr/bin/php5.6 drush --version is because you are telling /usr/bin/php5.6 to execute the drush file present in the current directory, but since you moved it to /usr/bin, it cannot find it. PHP doesn't look for the file in the PATH.

To use a specific PHP version to run Drush you need:

  • Set the DRUSH_PHP environment variable to the filename of the PHP executable

    • bash

      DRUSH_PHP="/usr/bin/php5.6" drush --version
      
    • Other shells (e.g. fish, tcsh)

      env DRUSH_PHP="/usr/bin/php5.6" drush --version
      
  • Tell PHP where to find the drush file

    /usr/bin/php5.6 /usr/bin/drush --version
    

Basing on a comment given for Modifying the PHP or PHP configuration that drush runs under, it seems the most recent versions of Drush don't use the DRUSH_PHP variable anymore.

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.