Last updated 19 May 2015. Created on 7 October 2011.
Edited by davidneedham, steveoliver, MacMladen, manish_mics. Log in to edit this page.

How to modify which PHP drush uses

You can set the environment variable DRUSH_PHP in your shell. Its value should be the /path/to/php. You can set it in your .profile or similar file to have it always available. Or you can alias drush with your own path to php version you wish to use. For instance, if you wish to use php 5.4 that is in /usr/local/php54/bin/php you should issue this command in terminal or include in your .bashrc or wherever you keep your aliases:

alias drush='DRUSH_PHP=/usr/local/php54/bin/php /home/dx_/drush/drush'

How to modify PHP settings if you do not have access to the system-wide php.ini?

Easy: look in the examples folder for example.drush.ini and follow the instructions there. This is useful if you need to change PHP memory_limit, max script execution time, disable_functions etc.

This is also useful if you want drush to use different PHP settings from the website itself. Note that since drush uses PHP-CLI, it is unaffected by PHP directives in httpd.conf, .htaccess, or a php.ini file in the Drupal root.

Alternately, you may also create your own php.ini file, and point the PHP_INI environment variable to it.

Using an alias to run drush.php directly from php

In the past, the Drush README.txt recommended creating an alias to drush.php, and run it directly with php. This technique is no longer recommended; always use the provided drush script and the DRUSH_PHP and PHP_INI environment variables to set the Drush environment to use.

If for some reason this proves to be impossible, and you must run drush.php directly, be sure to read the drush script and insure that your alias passes the --php and --php-options options, in the same way that the script does.

Looking for support? Visit the forums, or join #drupal-support in IRC.


ñull’s picture

Looks like modern versions of drush (mine is 8.01) don't respect the DRUSH_PHP any longer. What is the alternative alias?

zdd’s picture

Add an alias in .bash_profile or .profile in your home directory.

alias drush='/path-to-php /path-to-.composer/vendor/bin/drush'