Last updated 17 February 2017. Created on 30 October 2014.
Edited by MattWithoos, Anthony Pero, rwilson0429, alvar0hurtad0. Log in to edit this page.

NOTE: I'm getting reports that Git is now necessary to install Drush via Composer. I have not been able to confirm these. If you know anything about this, or have experienced this issue, please comment below.

Drush 6.2 and above require the Composer Dependency Manager. This guide will get you up and running with the latest versions of Drush on your Shared Hosting account. To install a previous version of Drush, see Installing Older Versions of Drush on Shared Hosting Accounts.

This guide is specific to Linux / Apache shared hosts. While it is possible to install Drush on a Shared Windows Server, the commands below are Linux-specific and will not work on a Windows Web Server. Please note that specific locations of files may change based on your host's environment. If you discover that your host keeps files in a different place, please note that in the comments below.

Requesting SSH Access

In order to use Drush, you will need SSH (Secure Shell) access to your shared hosting account. The process for enabling SSH will vary between hosts, and some hosts won't allow SSH access at all. In many cases, you can turn SSH (or Shell) access on via your account's control panel, or by submitting a support ticket. Refer to your host's Knowledge Base or Support Docs for more information.

You will also need an SSH Client. If you are on Windows, you can download PuTTY, a free SSH client for Windows. Mac users can just use Terminal, which is preinstalled. Firefox users on either platform can install the FireSSH extension. Chrome users on either platform can install the Secure Shell extension.

After gaining SSH access, open your SSH Client and login to your shared hosting account using the credentials given to you by your host. For Terminal users this will be


You will then be prompted for your password. PuTTY users have a slightly different login process. Please refer to the PuTTY help docs if you get stuck.

You are now logged in to your server using an SSH Client. On a Linux server, this shell program is called Bash, and commands are referred to as Bash commands.

Familiarize Yourself With Your Shared Hosting Environment

Take a few moments to try and locate some of the files and directories you will need to correctly install Drush, as they may not be in the exact same places listed here. This will help you follow the rest of this guide.

Type cd ~. This will change directories and move you to your home folder. Then, type clear. This will clear all old commands out of the shell and and make it easier for you to read the screen. Use this command as often as you need.

Next, type ls -a. This will list all files and folders (including hidden folders) within your home directory. Look for a file named .bash_profile, or .bashrc. Some systems have both.

Please note: some Web hosts that use Free BSD or other UNIX operating systems may not have a .bashrc file, but a .cshrc file, which you edit in the same manner.

We will use .bash_profile in this guide, but if you only have .bashrc, then use that one. If you have neither, please consult your host's Knowledge Base or Support Docs to find out how to add Bash aliases on your server.

Finally, look for a directory named bin/. Directories have backslashes after them and most SSH Clients display them in a different color than files. If you don't have a bin/ folder, try to follow this guide by removing any reference to bin/ from what you type.

Install Composer

Make sure you are still in your home directory by typing cd ~ and hitting enter, then type the following command into your shell:

curl -sS | php

This will download the installer from Composer's website and use php to run the installer. If you get a message saying curl is not installed, then replace curl -sS with wget and try again. If neither curl nor wget is installed on your system, try the following command:

php -r "readfile('');" | php

If successful, you should get output that looks something like this:

All settings correct for using Composer
Composer successfully installed to: /home/[username]/composer.phar
Use it: php composer.phar

If you do not get a similar message, your host may not be set up to correctly install Composer. Please refer to their support pages for additional information.

Some shared hosts run an older version of php from the command line by default. If you encounter this problem, you can set up an alias in .bash_profile (or .bashrc) to use the more current version of php that your web server is using. At the bottom of the file, add this line: alias php='path/to/php' where path/to/php is the path to the version of php your web server is running. Google how to find this path.

Next, we will move composer.phar, the file you just installed, to keep our home directory clean:

mv -p composer.phar ~/bin/composer.phar

Then, we will add a few lines to .bash_profile (or .bashrc) for ease of use. First, type nano .bash_profile to open .bash_profile up in the Nano text editor. For help in using the Nano text editor, visit here. Add the following line to the bottom of the file:

alias composer="/usr/php/54/usr/bin/php-cli ~/bin/composer.phar"

This sets up a command in bash that runs the script located at "~/bin/composer.phar" with the program located at "/usr/php/54/bin/php54-cli", in this case, the php-cli program. Not all hosts will have php-cli located at this location. Some hosts might not even have php-cli installed. You can check to see if php-cli is available and if so what the path to the program is by typing which php-cli at a command line prompt (NOTE: Not in Nano). If php-cli is available, this command will return the path. If it is not available, it will return nothing.

After adding the above alias to .bash_profile, type ctrl+x and follow the prompts to save the changes to this file.

Finally, you will need to reload your aliases for the new command to work. Type source ~/.bash_profile (remember to substitute .bashrc if that is where you put the alias!) then hit enter. Type composer to see if Composer is working. You should get a list of options if it is. If the command returns...

-bash: composer: command not found

...then try closing your SSH Client entirely, reopening it and logging back in. If the composer command still doesn't work, verify that you typed everything correctly in the preceding steps. If you get a specific error message, please leave a comment here.

Installing Drush

Congratulations, the hard part is over. If you successfully installed Composer, then installing Drush will be simple.

Drupal 8 requires Drush 7, so we will install the latest master from the repository. Type:

composer global require drush/drush:dev-master

If you need a different version of Drush, you can alter this command by specifying a version number:

composer global require drush/drush:6.4.0

That's it! Drush is now installed on your system. To make it easier to use, add another alias to your .bash_profile or .bashrc file by typing nano .bash_profile and then entering the following:

  alias drush="~/.composer/vendor/bin/drush"

Hit ctrl+x and follow the prompts to save your changes. Then reload the file by typing source ~/.bash_profile (or .bashrc, if that's where you made the changes), or simply closing your SSH Client and logging back in again.

Finally, type drush to see if your installation is working. You should get a list of options and some other drush-specific information.

If your shared host has different locations of files, but this guide works in general, please add a comment below with the specifics of your host. If your host requires completely different instructions, please create a new child page and add the instructions there.

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


docans’s picture

I got this error after following all the steps

Could not open input file: /home/linkgh/bin/composer.phar

What next

Anthony Pero’s picture

What host are you on?

Anthony Pero
Project Lead
Virtuosic Media

JackProbst’s picture

I think for the move step, the instructions should say mv composer.phar bin/composer.phar

I'm going to update the article

Anthony Pero’s picture

You can rename the file to whatever you want. the extensions are irrelevant. Most tutorials I see drop the .phar extension because its easier to type composer than composer.phar, when setting the path in following steps.

If you do decide to update the article, make sure you change it in all aliases and everywhere else.

Anthony Pero
Project Lead
Virtuosic Media

Anthony Pero’s picture

But I now see that the instructions weren't consistent in later steps with that rename, so per your suggestion, I've made it composer.phar throughout.

Anthony Pero
Project Lead
Virtuosic Media

junestag’s picture

Didn't bother trying to get an alias for composer but the rest of the article worked perfectly for me; got drush working on my server. thanks!

scott859’s picture

Very helpful - worked great on a shared host at HostMonster - thank you!

chrischee18’s picture

Hi guys.

I get this error message when I try to install Drush.

solidtra@phx15 [~]# curl -sS | php
#!/usr/bin/env php
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The phar extension is missing.
Install it or recompile php without --disable-phar

Anthony Pero’s picture

A few questions:

What host are you with?
Do you understand the error message?

The problem is that part of php is either uninstalled, or more likely, disabled on your server. You will most likely need to either refer to the help desk for your host, or make a call to support.

The most likely solution is that you have a php.ini file on your server that controls which php extensions are enabled, and your host can edit the file for you if you don't know how and turn the phar extension on.

Anthony Pero
Project Lead
Virtuosic Media

Rui Figueiredo’s picture

When following this guide, I couldn't get past the installing Composer step. My Shared Hosting account on Namecheap was running version 5.3 of PHP, which I think is their default setting. Finally, by changing the PHP version to 5.6, the issues with Composer went away and I could easily follow every step in this wonderful walk-through.

Hopefully this will help someone facing the same problem.

Anthony Pero’s picture

Glad you got it figured out! Hopefully this won't be an issue for very many people moving forward because PHP 5.3's End-of-Life was August of 2014. It is no longer supported, and won't run many modern plugins or modules.

Anthony Pero
Project Lead
Virtuosic Media

wahem’s picture

Hi, my host is Heart Internet and I get this error when trying to run the drush command after following the above instructions;

Error in argument 1, char 2: option not found r
/home/XXXX/.composer/vendor/bin/drush: line 129: [: too many arguments
PHP Notice:  Undefined index: argc in /home/XXXX/.composer/vendor/drush/drush/includes/ on line 423
PHP Notice:  Use of undefined constant STDERR - assumed 'STDERR' in /home/XXXX/.composer/vendor/drush/drush/includes/ on line 1408
PHP Warning:  fwrite() expects parameter 1 to be resource, string given in /home/XXXX/.composer/vendor/drush/drush/includes/ on line 35
X-Powered-By: PHP/5.3.28
Content-type: text/html

Any help would be much appreciated!

wahem’s picture

I managed to figure out what the problem was with the HeartInternet drush installation.

I had to explicitly choose the php version for the drush alias. So the two lines in my .bashrc file are as follows;

alias drush="/usr/bin/php54-cli ~/.composer/vendor/bin/drush.php"
alias composer="/usr/bin/php54-cli ~/composer.phar"

Hope that helps someone!

karolus’s picture

For Bluehost, there is a minor alteration to this:

alias composer="/usr/php/54/usr/bin/php-cli ~/bin/composer.phar"

alias drush="/usr/php/54/usr/bin/php-cli ~/.composer/vendor/bin/drush"

After adding this, and running source ~/.bash_profile, all was working for me.

ckoharj’s picture

I was having problems where drush status would not work. After searching everywhere your post solved my problem. Thank you

annrockio’s picture

Installed drush on shared hosting with no problems.

There is no bin/ folder so I left composer.phar in the home directory.
Running which php-cli shows /usr/bin/php-cli is the path to the program.

When editing .bash_profile the alias for composer for this set up is:
alias composer="/usr/bin/php-cli ~/composer.phar"

Thanks for the easy tutorial!

cliffskier’s picture

Thanks. These instructions worked for me. (The tutorial on GoDaddy's site caused an error message that I haven't been able to solve so far, even with their tech support.)

php-cli on their cPanel accounts is in a different location. I used "../../usr/bin/php5-cli" for the path from my home directory.

simohell’s picture

Thanks for the guide,

I installed version 6.5.0. I didn't find php5x-cli but drush seems to work except I get the following warning:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/' - /usr/lib/php5/20100525/ cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/' - /usr/lib/php5/20100525/ cannot open shared object file: No such file or directory in Unknown on line 0

Any idea how to solve, or what functionality is affected?

Anthony Pero’s picture

These are the image handling modules for PHP. If they are not installed, you will have limited functionality on your actual Drupal site, and won't be able to manipulate images through either Drush or your Drupal interface.

Go into your root web directory. Type: nano phpinfo.php

In the text file that is created, type

<?php phpinfo(); ?>

Then save the file by typing CTRL+X and following the prompts.

Go to

Search through the page to find what PHP modules are installed and specifically if ImageMagick and GD are listed. If they are, then post the info of the entire page here, making sure to delete or obfuscate any information that says what your real domain name is. This is not information you want to give the World Wide Web usually. I will try to help you figure out why Drush is not finding the modules in PHP.

If they are NOT listed in the modules section, you'll need to refer to your hosts documentation to find out if you can turn them on. If its host monster or BlueHost, you can turn them on through cPanel.

Anthony Pero
Project Lead
Virtuosic Media

garyebickford’s picture

On Bluehost, the path to use in the alias is slightly different:

alias composer='/usr/php/54/usr/bin/php-cli ~/bin/composer.phar'

Other than that installation went fine. I used the 'master' version, where it says "Drupal 8 requires Drush 7", hoping that would work as well for Drupal 7. It took several minutes to install drush, then add the alias and all done.

composer global require drush/drush:dev-master

echris’s picture

After successfully installed Composer, I tried to install drush and i get this nasty error:

Failed to execute git status --porcelain --untracked-files=no
sh: git: command not found

Please what could have gone run? I am running it on a server with php 5.4 installed using .bashrc. Your candy help would be grateful

Anthony Pero’s picture

Huh... its seems to want Git installed in order to install Drush... I have not experienced that before. See your hosts helpdocs or knowledge base for information on how to install Git, or try installing Git using the instructions found here if your host doesn't have such infromation. Then try running the drush installation command again.

Anthony Pero
Project Lead
Virtuosic Media

garpy’s picture

Excellent instructions. Checking to see where the host had the files was the best part of the explanation because in my case it was not just a copy and paste. The correct path had to be determined by checking just as the instructions ask. Great page.

Bartelli’s picture

I can install composer on my shared hosting ( but when I try to install drush I get this error:

escapeshellarg() has been disabled for security reasons

Any work around for this? I don't have access to the php.ini file.

I guess my host didn't forgot disable escapeshellarg for php5.6. I switched php versions and the install went flawlessly.

mnevens’s picture

I installed composer and drush like described in post. When I type command drush I have following message: /urs/bin/env: sh: No such file or directory
I have a shared linux hosting at
I need some help.
Thank you in advance

MarkDQ’s picture

These are the two lines i put in .bash-profile (shared hosting at

alias composer="/etc/cl.selector/php-cli ~/bin/composer.phar"
alias drush="~/.composer/vendor/bin/drush"

where ~ stands for /home/[account name]/public_html

stephenevans’s picture

I'm using BLUEHOST

I installed drush 7 since I'm running drupal 7. I ran “composer global require drush/drush:7.*” instead.

composer was located at a slightly different folder:
"alias composer="/usr/php/54/usr/bin/php-cli ~/bin/composer.phar"

my drush was located at:
"alias drush="~/.composer/vendor/drush/drush/drush"
At the very last step, I had to run "source ~/.bashrc" after changing the .bashrc file again.

Works though! Thanks for the clear directions!

abhai_zyxware’s picture

Just follow this to word for the latest drush installation :

Anthony Pero’s picture

Looks like a good tutorial for VPS or dedicated server users. Most of the audience for this page is for shared servers, though.

Anthony Pero
Project Lead
Virtuosic Media

TheodorosPloumis’s picture

I have a created 2 bash scripts that install Drush on shared hosting either with git or not.

In case everyone needs them.

------------------------ - Freelance Drupal developer.

fabius’s picture

Thanks. Excellent work and badly needed (the composer and drush home sites are sketchy in some areas).

1. Part way through you say run "source ~/.bash_profile". I am not sure what that's for, probably the system needs to be aware of the changes. It throws an error on my ssh terminal: "-bash: #: command not found". I thought I had done something wrong but things worked better once I got the alias right.

2. I have a multisite Drupal 6 folder and a D7 sub-folder with one site. I keep worrying about what problems that might create. For example, each has it's own php.ini. I guess that's taken care of somewhere else.

Thanks again.

Anthony Pero’s picture

Drush acts on the site and database whose folder you are within, so I imagine if you are within the D7 folder, it will only act on the D7 site and database, similarly to how it works in multisite. Which is to say, when you are in the root folder, or anywhere outside the "sites" folder, it acts on the database stored in the settings.php within the "sites/default" folder. In order to act on another multisite, you have to be within "sites/".

Let us know how that goes, please!

Anthony Pero
Project Lead
Virtuosic Media

fabius’s picture

Thanks Anthony. Yes, I tried various options in the d7 folder and drush refused to update until I moved to the /sites/sitename folder. It automatically recognized that D7 was required. I issued "drush -v up". It performed a number of actions and then tried to load the update_status engine. That failed as follows:

php /home1/xxxxx/.composer/vendor/drush/drush/drush.php  --backend=2 --verbose --root=/home1/xxxxxx/public_html/d7 --uri=  pm-updatestatus 2>&1                                 [notice]
Illegal string offset 'site'                                                                                                                                                           [warning]     [error]    , code: 1)
pm-updatestatus failed.   

I found is in the drush folder. The same error message is printed if I try the uri option (drush -l sitename update. However this did not occur when I updated the D6 multisite, which is updated and working fine. Therefore I conclude I did something wrong in the meantime.

Here is the status report (note the exact paths used by drush despite aliases):

Drupal version                  :  7.38                                                   
 Site URI                        :  http://sitename                              
 Database driver                 :  mysql                                                  
 Database hostname               :  localhost                                              
 Database port                   :                                                         
 Database username               :  xxxxxxxx                                        
 Database name                   :  xxxxxxx                                        
 Drupal bootstrap                :  Successful                                             
 Drupal user                     :                                                         
 Default theme                   :  bartik                                                 
 Administration theme            :  seven                                                  
 PHP configuration               :  /usr/php/54/etc/php.ini                                
 PHP OS                          :  Linux                                                  
 Drush script                    :  /home1/username/.composer/vendor/drush/drush/drush.php 
 Drush version                   :  7.0.0                                                  
 Drush temp directory            :  /tmp                                                   
 Drush configuration             :                                                         
 Drush alias files               :                                                         
 Install profile                 :  standard                                               
 Drupal root                     :  /home1/username/public_html/d7                         
 Site path                       :  sites/sitename                                
 File directory path             :  sites/sitename/files   
Anthony Pero’s picture

I've never heard anything good about keeping a separate code base within an existing codebase. Is there a reason you are structuring your server that way?

Anthony Pero
Project Lead
Virtuosic Media

fabius’s picture

no particular reason. It works well with drush. Could be related to the 'offset' failure when all the other drush commands function normally?

I tried to understand the code in but failed to see where the variable 'site' originated. I suspect the problem lies with the site's db. I am going to create and test other sites. Could 'drush sql-sanitize' help? My db is mysql.

hash6’s picture

[~]$ composer
PHP Fatal error: Class 'Phar' not found in /bin/composer.phar on line 23

When I installed composer successfully
I typed source ~/.bash_profile

After that I typed composer and I got the above error

Its a shared hosting hsphere and cent OS
On searching related article to the above I found
Please let me know how can I fix the above error so that I can install drush

Anthony Pero’s picture

Copy and paste what you added to your .bash_profile or .bashrc file.

Anthony Pero
Project Lead
Virtuosic Media

kathc’s picture

I have an Enhanced Shared account on CWH. It has SSH access, but I needed to open a ticket with them to get composer installed :

I have disabled PHP function exec and also added the following line in php configuration:

suhosin.executor.include.whitelist = phar

When I got to adding the alias, I looked up the php-cli by doing "which php-cli" for the correct path.

Thanks for the very clear directions.


alar’s picture

I got an error, and I don't have access to php.ini

Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The suhosin.executor.include.whitelist setting is incorrect.
Add the following to the end of your `php.ini` or suhosin.ini (Example path [for Debian]: /etc/php5/cli/conf.d/suhosin.ini):
    suhosin.executor.include.whitelist = phar 

The php.ini used by your command-line PHP is: /usr/local/lib/php.ini
If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.

This fixed it:

[user@serverABC drush]$ curl -sS | php -d suhosin.executor.include.whitelist=phar
All settings correct for using Composer
Downloading 1.2.2...

Composer successfully installed to: /home/user/drush/composer.phar

The tricky bit for me, was to make sure there are no spaces in

Hope this helps somebody else.

hangoverocks’s picture

Thank you Anthony Pero, littledynamo...
...for this walkthrough, which it took me a day to find! And only half a day to implement! (I´m not a newbie but I am generalist)
an early mybad was reading "ls -a" as "Is-a" (I read capital "i", where it should be lowercase "L", took ahalf an hour to resolve that!)
I was often checking my ftp view using Filezilla which did not show usr/bin but PuTTY revealed both directories and the path to php-cli.
On HostGator:
composer.phar did not want to move outside the root directory.
php-cli is in /usr/bin so I had to change the .bash_profile command to:
alias composer ="/usr/bin/php5-cli ~/composer.phar"
That was the worst of it, after this route was resolved the rest was relatively painless. I wouldn´t have been able to do it without you, thank you so much.

Anthony Pero’s picture

That is a setting in filezilla. Its probably hiding certain folders and hidden files by default.

Anthony Pero
Project Lead
Virtuosic Media

hangoverocks’s picture

duplicate of above -delete

MartinMa’s picture

composer was still installed at bin/composer.phar

installing drush with composer seems to work

aliasing composer works too (have no .bash_profile file but alias comand works)

but aliasing drush in different versions doesnt work :-(

alias drush="~/.composer/vendor/bin/drush"
[17:31:51] server451-han:~/ > drush
PHP Fatal error: Call to undefined function drush_startup() in /medjxcwh/.composer/vendor/drush/drush/drush on line 115

alias drush="/usr/local/php5.5/bin/php ~/.composer/vendor/bin/drush"
[17:37:12] server451-han:~/ > drush
PHP Fatal error: require(): Failed opening required '__DIR__/includes/' (include_path='.:/usr/local/php5/lib/php') in /medjxcwh/ on line 11

alias drush="/usr/local/php5.5/bin/php ~/.composer/vendor/bin/drush"
[17:38:12] server451-han:~ > drush
PHP Fatal error: require(): Failed opening required '__DIR__/includes/' (include_path='.:/usr/local/php5/lib/php') in /medjxcwh/.composer/vendor/drush/drush/drush.php on line 11

> alias drush="/usr/local/bin/php-cli ~/.composer/vendor/bin/drush"
[17:47:59] server451-han:~ > drush
PHP Fatal error: Call to undefined function drush_startup() in /medjxcwh/.composer/vendor/drush/drush/drush on line 115

what can I do? I'm not so firm with that stuff ... :-(

MarkDQ’s picture

Drupal is installed in 3 subfolders:
1. public_html/web01 = production with drupal01 as database
2. public_html/web02 = staging with drupal02 as database
2. public_html/web03 = test with drupal03 as database

How install composer and drush for each site?

Or do the websites have to be moved to subsites in folder ../sites
with no modules and themes in ../sites/all because they are different?

ckoharj’s picture

Installed Drush with composer as per instructions and have it working on one Hostmonster account.
On another account when I enter "drush status" in root directory I get the configuration display for drush.
But when I go to the websites drupal directory and enter "drush status" I get:
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Cannot redeclare drush_print_help() (previously declared in
in /home5/username/drush/commands/core/, line 112

which php-cli tells me this:

alias composer="/usr/php/54/usr/bin/php-cli ~/bin/composer.phar"
alias drush="~/.composer/vendor/bin/drush"

Any ideas what to try next?

Raven Dog’s picture

I had issues installing as well.
I installed Drush 7 and NOT the master-dev as its status reported failing.

Not sure if this can help you, but I hope so.

ckoharj’s picture

Thanks. Not sure exactly how I resolved it but I think it ended up that the PHP version was only 5.2 and had to be changed to 5.3 minimum. Sometimes the error does not always state that outright.

Update: A couple weeks ago Hostmonster changed something and now the version of PHP used for the Command Line installation is only 5.2.17 so Drush no longer works on shared hosting accounts there. I spoke to them and they said it cannot be changed. The version used for websites is different than the command line installations and you have no control over that in a shared hosting account. I even tried installing a version of Drush 5 (whatever the latest is) but that seemed to still require 5.3

lu_smithcon’s picture

@ckoharj - I also use Hostmonster and have started getting errors with Drush 6.4.0, though their ssh has been set at php 5.2.17 for quite a while. It seems the path to php 5.4 is what changed so we have to set a new path for export DRUSH_PHP. I gave HM a call and with the help of a good support rep was able find a working path. The support rep added alias php=php54s to .bashrc (though I'm not sure it is needed), and .bash_profile now has:

# User specific environment and startup programs
alias composer="/ramdisk/php/54/bin/php54-cli ~/bin/composer.phar"
alias drush="~/.composer/vendor/bin/drush"
export DRUSH_PHP=/ramdisk/php/54/bin/php54-cli

and drush is working once again and I updated it to 7.4.0.

I changed the alias in .bashrc to read:

# User specific aliases and functions
alias php=/ramdisk/php/54/bin/php54-cli

You can check the php path by using ls /ramdisk/php/54/bin/php54-cli or ll /ramdisk/php/54/bin/php54-cli. I was able to use that path for several Hostmonster accounts and a Bluehost account.

If using source ~/.bashrc doesn't work to reload .bashrc, exit and restart ssh for the new php version to take effect. It can be checked by typing php -v.

On another client site (Bluehost), I created the php alias in .bashrc prior to installing Composer so it would be installed using php5.4 php-cli (may not be necessary on Bluehost or Hostmonster but I did need to specify a path to php 5.4 for composer install on 1and1 hosting).
Installed Composer using:
curl -sS | php
/bin directory did not exist so I created it,
mkdir bin
moved composer.phar as suggested above,
mv composer.phar bin/composer.phar
added the composer alias to .bash_profile,
alias composer="/ramdisk/php/54/bin/php54-cli ~/bin/composer.phar"
reload .bash_profile,
source ~/.bash_profile
checked to make sure Composer was good by entering composer which should return the available Composer commands.

I chose to install Drush 7
composer global require drush/drush:7
added the following lines to .bash_profile

alias drush="~/.composer/vendor/bin/drush"
export DRUSH_PHP=/ramdisk/php/54/bin/php54-cli

reload .bash_profile,
source ~/.bash_profile
check Drush by typing drush or drush status.

ckoharj’s picture

Thank you for this information. You were certainly lucky to get someone to help you. Their typical response is that is above the level of support they provide.
I was not able to get it working by modifying the files as you suggested. What is "ramdisk"? Is that a username or is that part of the path? Can you send the complete contents of each of your profile files?

ckoharj’s picture

Thanks. Sure enough ll /ramdisk/php/54/bin/php54-cli did return a valid path. I updated the .bash_profile and the .bashrc files as you wrote and got Drush working on 2 Hostmonster accounts.

davidneedham’s picture

Here's what my ~/.bash_profile looks like on Hostmonster:

export PATH=$PATH:$HOME/bin

alias php='/usr/php/56/bin/php'
export PATH="/usr/php/56/bin:$PATH"

export PATH="$HOME/.composer/vendor/bin:$PATH"

alias drush="$HOME/.composer/vendor/bin/drush"
export DRUSH_PHP=/usr/php/56/bin/php

Once I figured out where php was stored on the server (/usr/php/) I was able to set that alias and install composer using PHP 5.6. Once composer was installed at ~/bin/composer, I installed Drush with composer. Everything seems to work well so far, but I'm sure there this could be streamlined.

Good luck!

David Needham
Agency & Community Training Manager | Pantheon

vincer’s picture

My changes were...

I didn't have /bin in my home directory, so I created it with:
mkdir bin

My php-cli was in..
So, I used the alias..
alias composer="/usr/bin/php-cli ~/bin/composer.phar"

I failed installing the Drush master, so I ran:
composer global require drush/drush:8.*

Lanoxx’s picture

I am using Ubuntu 16.04 which comes with PHP7, so the above command for the composer alias did not work for me. Instead I had to use the following command:

alias composer="/usr/bin/php $HOME/.local/bin/composer/composer.phar"

You might want to update this post to include instructions for PHP7

Also I could not find any php-cli binary on my system or via the package manager, maybe you could clarify in your post the difference between the php and php-cli binaries and if php-cli they are still necessary for PHP7?


mnojind’s picture

We have used command line : /usr/php/56/bin/php bin/magento indexer:reindex
Happy New Year 2018