Install Composer on Bluehost


I ran into this problem a little while back when trying to install composer on Bluehost. While the PHP version used on Apache was a relatively modern v. 5.4, the command line was running php v. 5.2. Following the composer install procedure:

curl -sS | php

I kept getting the following error:

Status: 500 Internal Server Error
Content-type: text/html

It turns out, that Composer requires PHP 5.3.2+ to run, so how was I to access PHP 5.4 from the command line? It turns out that on Bluehost, you can access it directly at /ramdisk/php/54/php54-cli. So I did the following to make sure composer was available whenever I would ssh into the system:

  1. Created a directory off of my home directory called “common”

mkdir ~/common

  1. cd into the common directory

cd ~/common

  1. Install composer using php 5.4

curl -sS | /ramdisk/php/54/bin/php54-cli

  1. Set up an alias to composer using the php 5.4 command line in the .bashrc file

echo “alias composer=’/ramdisk/php/54/bin/php54-cli ~/common/composer.phar'” >> ~/.bashrc

  1. Run the following to make the changes take effect (thanks to the comments below for this):

source ~/.bashrc

And from there on out, I’ve got access to composer whenever I’m logged in. Keep in mind if you’re wanting to run it from a cron job, your alias won’t be available, so you’ll need to use the full path.

Author: Jared

Flying, software, diving

14 thoughts on “Install Composer on Bluehost”

  1. Thanks for this! For myself, I had to use “php-cli” instead of the full path you used here in order to get composer to run properly.

    This meant that the alias command changed to this:

    echo "alias composer='php-cli ~/common/composer.phar'" >> ~/.bashrc

    Might work differently for those who still have PHP 5.3 running on their server, though.

  2. You should add that after adding the alias to their .bashrc file they need to run “. ~/.bashrc” (note the space between the “.” and “~/.bashrc”) in order for the alias to take effect.

  3. When you say you create the common folder in your home directory, do you mean i.e. /home2/common or /home2//common? Also do you just run the following line in the command prompt: echo “alias composer=’/ramdisk/php/54/bin/php54-cli ~/common/composer.phar’” >> ~/.bashrc? if so that doesn’t work for me.

    1. The tilde (~) is a reference to your home directory. If your login is my_login, then it would be something like /home2/my_login. You can also just write it out completely instead of using the tilde symbol.

  4. Sweet. That did the trick. You rock!

    Dan is right though, you should probably remind people to do ‘source ~/.bashrc’ to refresh the file so the alias works.

Leave a Reply

Your email address will not be published. Required fields are marked *