2

On live server I use differents drush and php versions for drupal 8.4 and 7. I install drush 9 to ~/drush9 directory with composer require drush/drush:9.* command.

On dev server and drupal 8.4 I use site.alias.yml file for drush 9:

live:
  host: hostingexample.com
  user: user
  root: /home/user/example.com/public_html/
  uri: http://example.com/
  paths:
    drush-script: '/opt/php70/bin/php /home/user/drush9/vendor/bin/drush'

And for command drush @site.live ev 'print PHP_VERSION' have an error: bash: /opt/php70/bin/php /home/user/drush9/vendor/bin/drush: No such file or directory

If I add

alias php=/opt/php70/bin/php
alias drush9=~/drush9/vendor/bin/drush

in hosting .bash_profile and change drush-script: '/home/user/drush9/vendor/bin/drush' in site.alias.yml. And have an error PHP Parse error: syntax error, unexpected '[' in /home/user/drush9/vendor/drush/drush/src/Config/Environment.php on line 98. Because on hosting default php version is 5.3.

How to use another php version for hosting and config it for drush 9 aliases?

0

Try editing both the .bash_rc and .bash_profile files so that you include the directory where the version of PHP you want is FIRST (before existing PATH):

(add this line or adjust if existing):

export PATH="/opt/php70/bin:$PATH"

As a last ditch effort, you can set the env variable drush looks for as well in these files:

DRUSH_PHP=/opt/php70/bin/php

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.