Install Composer On Shared Hosting The Easy Way

Tuesday, February 28th, 2017
Last Updated:
Sunday, August 13th, 2017

Disclaimer: Accessing the information on this page means you agree to the Sites Terms of Service

I have a long involved method to install composer on a shared environment, but it is now outdated in favor of the PHP .phar binary method. Composer wasn't setup to use the phar extension when I originally wrote the old article but now that the .phar method is available, it is WAAYYY easier to install.

This guide will assume you have CLI shell access through SSH. If you don't know what it is, you'll want to learn how to use it before you proceed. There's really no point in using Composer without a CLI anyway, so I'll assume you know it.

Step 1 - Download Composer

1) Navigate out to and scroll down to the Manual Download section.
2) Right click and copy the link location
3) In the ssh terminal, navigate to your home directory bin folder ~/bin If it doesn't exist, go ahead and create it
4) Go into the ~/bin folder and issue the following command (changing the version number to whatever the latest is):

wget --no-check-certificate

5) Run the chmod 744 command to give yourself execute permission on the file
chmod 744 composer.phar

Step 2 - Create An Alias To Composer

1) Change directories back to your home directory
2) Edit either the .bashrc file (might be .bashrc_profile file depending on your setup)
3) Create an alias to the composer.phar:

alias composer='~/bin/composer.phar'

4) Reload the .bashrc file by issuing the source command on it
source .bashrc

Step 3 - Test composer

If everything went as planned, you should be able to simply issue the command composer and get the run out of commands. If you don't get the run out of commands, I may have forgotten something, or, you didn't get a step quite right...

If you use Drupal and Drush, you can either use composer to install drush, or you can follow the similar procedure to use the drush.phar file.

Post Comment