0

The Problem:

For reasons I'm not gonna get into, the path to my php executable is NOT /usr/bin/php but is instead something else (let's say it's /local/path/to/php).

My staging and production servers do use /usr/bin/php, however; Moreover, the non-standard php path doesn't exist on those servers.

The problem is that whenever I run a Drush command for a remote site, I get an error:

$ drush @mysite.remote status
bash: /local/path/to/php: No such file or directory

Since /local/path/to/php definitely exists on my local machine (or else my local sites wouldn't work and drush would fail) I can only assume that error is coming from the remote server.

I know I can pass --php=/usr/bin/php to Drush, but there are some less Drupal-savvy devs on my team, so I want to get it configured for them so they don't have to think about it.

I also know about the $DRUSH_PHP environment variable, but setting that to /usr/bin/php breaks drush on my dev machine entirely, so that's not an option either. It just straight-up breaks Drush.

The Question:

Is there a way to configure my remote aliases to use a specific path to PHP that is different to my local machine's PHP path? (And why is a remote server trying to use a local path to PHP in the first place?)

If not, what workarounds are there? (I'm hoping I won't have to create a symlink at /non/standard/php to /usr/bin/php on my servers, because that feels fragile and hack-ish, but if there are no alternatives, it'll have to do.)


Drush 7.4.0

1 Answer 1

2

From example.aliases.drushrc.php:

Although most aliases will contain only a few options, a number of settings that are commonly used appear below:

...

'php': path to custom php interpreter. Windows support limited to Cygwin.

So try somtehing like:

$aliases['example'] = array(
  'uri' => 'example.com',
  'root' => '/var/www/example.com',
  'remote-host' => 'www.example.com',
  'remote-user' => 'user',
  'php' => '/path/to/php/on/the/server'
);

You could try that. If this doesn't work I would suggest to update your drush version (locally and on the server) and try again, before doing any strange symlinking on the server.

2
  • Yep, this worked like a charm. I went up and down that example file I thought a million times and couldn't find anything about PHP, so I don't know how I missed that. Thanks!
    – calvin
    Commented Jun 6, 2017 at 17:24
  • any idea how to do this in Drush 9?
    – bleen
    Commented Mar 9, 2019 at 3:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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