Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Install Composer on Shared Hosting

Composer is a tool for PHP projects. This guide shows how to install it in your own account, even without root access.

Web Hosting2 min read11 steps15 screenshots

What is Composer?

PHP is a language that many websites use. Many PHP projects depend on code written by other people. These add-ons are called packages. Composer downloads the right packages for your project and keeps them up to date. Think of it as a shopping assistant that fetches all the parts on your list.

On shared hosting you cannot install software for the whole server. But you can put Composer in your own home folder. You need SSH access. If it is not on, ask Hostvento support whether your plan includes it.

Steps

  1. Connect to your account with SSH. SSH lets you type commands on the server.
    Screenshot: Connect to your account with SSH. SSH lets you type commands on the server.
  2. Go to your home folder:
cd ~

This moves you to your own home folder.

  1. Check that PHP works:
    Screenshot: Check that PHP works:
php -v

This prints the PHP version.

Screenshot: This prints the PHP version.
Screenshot: This prints the PHP version.
Screenshot: This prints the PHP version.
  1. Download the Composer installer:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

This saves the installer file in your folder.

  1. Run the installer:
    Screenshot: Run the installer:
php composer-setup.php

This creates a file called composer.phar. A phar file is a PHP program packed into one file.

Screenshot: This creates a file called composer.phar . A phar file is a PHP program packed into one fi
  1. Delete the installer:
php -r "unlink('composer-setup.php');"

This removes the setup file you no longer need.

  1. Test Composer:
php composer.phar --version

This prints the Composer version.

Make a short command

  1. Make a folder for your own programs:
mkdir -p ~/bin
mv composer.phar ~/bin/composer

This moves Composer into the bin folder with a shorter name.

Screenshot: This moves Composer into the bin folder with a shorter name.
Screenshot: This moves Composer into the bin folder with a shorter name.
Screenshot: This moves Composer into the bin folder with a shorter name.
  1. Make it runnable:
chmod +x ~/bin/composer

This lets the system run the file as a program.

Screenshot: This lets the system run the file as a program.
Screenshot: This lets the system run the file as a program.
Screenshot: This lets the system run the file as a program.
  1. Add the folder to your path. The path is the list of places where the system looks for commands:
echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

This adds the folder and loads the change.

  1. Now type:
composer --version

Use it

Go to your project folder and run composer install to get the packages in composer.json.

Screenshot: Go to your project folder and run composer install to get the packages in composer.json .
Tip: If you see a memory error, run php -d memory_limit=-1 ~/bin/composer install. Also check that your PHP version suits your project. If the commands are blocked, open a support ticket.

Quick recap

  • Composer manages PHP packages.
  • Install it in your home folder, not server wide.
  • Download, run and test the installer.
    Screenshot: Download, run and test the installer.
  • Move it to ~/bin for a short command.