Knowledgebase Home / How to install Composer on Shared servers

How to install Composer on Shared servers

Composer helps in managing dependencies in PHP. You can declare the libraries your project depends on, and it helps in managing (install/update) them for you. Composer isn’t a package manager similar to Yum or Apt. It works with ‘packages’ or libraries, but manages them on a per-project basis, installing them in a directory (e.g., vendor) within your project. Nothing will be installed globally by default. Composer enables you to manage dependencies for each project independently. Hence, it is a dependency manager.

Installing composer

To install composer, follow these steps:

  1. SSH access should be enabled for your hosting account with us.
  2. To access your account via SSH, download and install one of the available SSH clients.(like puTTy/Xshell) You can find the list of free SSH clients here or For a cPanel account you can access shell access via ADVANCED >> Terminal
  3. Composer requires PHP 5.5+ version, so we need to check whether the needed version is set up. Type the php -v command in PuTTY (or in Terminal) and you will get the following output
  4. If you need to change PHP version, log in to your cPanel, navigate to the Software and Services section >> Select PHP Version menu. For more details refer to the link: https://www.veerotech.net/kb/php-version-selector-change-php-version/

    PLEASE NOTE: Composer requires allow_url_fopen. It is enabled by default for all php versions on our Shared servers. Still, you may check if it is On by going to ‘Options’ Settings in the Select PHP version menu.

  5. Next, navigate to the folder you want to install Composer in. In our example, we will install Composer in the ‘newdomain.com‘ folder.
    cd newdomain.com
  6. When all the preparations are done, you are ready to install Composer. Open the PuTTY window/terminal where you have logged into your cPanel account and fill in the following command.
    php -r “readfile(‘https://getcomposer.org/installer’);” | php -c php.ini
    or
    To download the composer installer, type the following commands.
    cd newdomain.com

    curl -k -O https://getcomposer.org/installer

    To install composer, type the following command.

    php -d allow_url_fopen=On installer

    This will execute the Composer installation

  7. To confirm the composer installed correctly, type the following command.
    php composer.phar -V 

    The composer should display the version number.

  8. To update the composer installation to the newest version in the future, type the following command:
    php composer.phar self-update 
  9. To run composer commands use:
    php composer.phar

    In case you get a notification Some settings on your machine make Composer unable to work properly, make sure that the PHP version is 5.5 or higher.

If the steps above listed in this article do not resolve your issue, please feel free to open a support ticket and we’d be happy to take a look.

Our Guiding Principles

  • Provide consistent, stable and reliable web hosting services.
  • Ensure rapid ticket response and quick resolutions to issues.
  • Never saturate or over-provision servers to ensure stability and speed for our customers.
  • Use only high quality enterprise-class hardware to ensure minimal downtime from hardware failures.
  • Provide clear pricing with no hidden fees or gotchas.