By Rob Brandt


2017-07-12 23:23:52 8 Comments

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?

2 comments

@kiamlaluno 2017-07-22 18:11:42

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.

@Rob Brandt 2017-07-21 23:32:33

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.

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] Drush php-script | Drupal functions such as node_load() are not being found

  • 2014-06-28 07:51:17
  • Francisco Luz
  • 1177 View
  • 1 Score
  • 2 Answer
  • Tags:   drush

1 Answered Questions

Can't install drush8, having drush6

  • 2018-03-06 09:47:05
  • WhiteCollar
  • 72 View
  • 0 Score
  • 1 Answer
  • Tags:   drush

1 Answered Questions

[SOLVED] drush 8.1.9 on php 7 not giving any "drush status" in docroot folder

  • 2017-08-02 19:53:44
  • Patoshi パトシ
  • 208 View
  • 0 Score
  • 1 Answer
  • Tags:   7 drush

1 Answered Questions

2 Answered Questions

[SOLVED] Drush commands report "hostname: Name or service not known"

  • 2014-12-12 01:48:06
  • John
  • 2996 View
  • 3 Score
  • 2 Answer
  • Tags:   drush

1 Answered Questions

[SOLVED] How do I link drush to my drupal site thats hosted via localhost?

  • 2016-06-16 08:47:50
  • Shawn
  • 427 View
  • 0 Score
  • 1 Answer
  • Tags:   7 drush

1 Answered Questions

[SOLVED] Drush 8 raises an error while running 'drush runserver'

  • 2016-04-09 16:08:12
  • Andrea
  • 746 View
  • 0 Score
  • 1 Answer
  • Tags:   8 drush

Sponsored Content