By default, Composer is pre-installed on HostBrook and GoDaddy hostings, but you do not have a possibility to update to the newest version because you don't have root permissions at the shared hosting plans. But this is not a problem at all. In this article, we explain how to install Composer locally, just for your cPanel account.
You have two options to get access to your cPanel command line:
Via terminal emulator, like PuTTY
Note: Do not forget to enable SSH at the server settings of your account:
Manage WebHosting -> Dashboard -> Settings -> tab "Server" -> SSH access -> Manage
Using online interface in the cPanel:
cPanel Admin -> section "Advanced" -> Terminal
Go to Home Directory and create directory for the Composer:
cd ~
mkdir -p bin/composer/
cd bin/composer/
Install Composer locally:
curl -sS https://getcomposer.org/installer | php
ln -s ./composer.phar composer
Use the command:
which php
and copy the path you got, you'll need it for the next step.
You need to edit the file ~/.bashrc
to make an alias. You can use either the online editor provided in cPanel File Manager or vi editor in CLI:
vi ~/.bashrc
When file is open, just add the line with Composer alias at the section "User specific aliases and functions"
alias composer="/usr/local/bin/php ~/bin/composer/composer.phar"
Note: use path to PHP from the prevous step.
"Escape"
Type :wq
then press "Enter"
."Escape"
Type :q!
then press "Enter"
.
Reload the file ~/.bashrc
and check if newest version of Composer avalaible:
source ~/.bashrc
composer -v
Now you can use the latest version of the Composer in any folder at your hosting.
Use composer self-update
command to keep your Composer updated.