Skip to content

How do I add Composer to my hosting account?

Composer is not in the $PATH on cloud web hosting servers because the Composer package is continually updated. We instead recommend installing and maintaining your own Composer version compatible with your applications and workflow.

  1. Connect to your hosting account via SSH (How do I log into SSH (shared / cloud web hosting?)

  2. Create a .local/bin directory in your home directory if it is missing:

    Terminal window
    mkdir -p ~/.local/bin
  3. Navigate to the bin directory:

    Terminal window
    cd ~/.local/bin
  4. Download Composer:

    Terminal window
    curl -s https://getcomposer.org/installer | php -- --filename=composer
  5. Make Composer executable:

    Terminal window
    chmod +x composer

You can verify that Composer is installed correctly by running:

Terminal window
composer --version

If you get a “command not found” error, you may need to add the ~/.local/bin directory to your $PATH.

New accounts should have the ~/.local/bin directory in their $PATH by default. Depending on the age of your account, it may be missing. You can add your bin folder to $PATH by doing the following:

Find the following line in your ~/.bashrc file:

Terminal window
# User specific environment

Below it, add the following:

Terminal window
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH

Once added, reload your shell configuration:

Terminal window
source ~/.bashrc

As you are managing your own Composer installation, you will need to update it manually when new versions are released. To update Composer to the latest version, run the following command:

Terminal window
composer self-update