How to use Composer at Bluehost Shared hosting

I am trying to create my own Laravel project, I need to use composer to update my vendor. I tried to use composer install at my repo using ssh, however, the ssh does not recognize composer command. I found this post. It says that by default, Bluehost comes with PHP 5.2 command line while Composer needs PHP 5.3 to run. Fortunately, Bluehost gives access to PHP 5.4 command line. It is as /ramdisk/php/54/php54-cli.

First, install Composer using the PHP 5.4.

  1. Make a directory called common at your root.
    mkdir ~/www/common
  2. cd into the directory.
    cd ~/www/common
  3. Install composer using php 5.4
    curl -sS https://getcomposer.org/installer | /ramdisk/php/54/bin/php54-cli

Second, setup an alias for Composer.

  1. Set alias
    echo “alias composer=’/ramdisk/php/54/bin/php54-cli ~/www/common/composer.phar’” >> ~/.bashrc
  2. Make alias into effect.
    . ~/.bashrc

Done, now you can go into any directory and run Composer.

For my case, I can go into my Laravel repo and do Composer install or Composer update.

Leave a Reply