How to Install Composer on Shared cPanel Hosting
When you need Composer to install or manage PHP dependencies on shared hosting. This article explains how to install Composer on shared cPanel hosting.
Composer is a dependency manager for the PHP programming language. It functions as a project manager that helps the programmer manage dependencies that will be used on a project to project basis. Dependency is an engineering term used to refer when a piece of software relies on another one.
After installing composer, you can install various packages from the composer repository and use the appropriate versions of the same in your PHP code.
Installation steps:
1. Make sure allow_url_fopen is enabled under cPanel>Software>MultiPHP editor>Basic Mode:
Please check the below illustration:

2. Make sure PHP version is set to 5.5 and above in cPanel>Software>MultiPHP Manager.
3. SSH into your account space on the shared server. You can follow the detailed steps in this guide:
4.. Go to cPanel>Files>File Manager and create a php.ini file in the folder you wish to install composer under with the below code:
suhosin.executor.include.whitelist = phar
detect_unicode = Off
allow_url_fopen=On
5. Navigate to the directory you wish to install composer under. For example, if you wish to install composer under the ‘public_html’ folder, you may navigate to /home/username/public_html with the below command
~~~
$cd /home/username/public_html
~~~
If you wish to install composer on a custom folder, you can create one and change the working directory to the same:
~~~~~
mkdir /home/username/public_html/composer
cd /home/username/public_html/composer
~~~~~~
6. Then Run the following command in your SSH terminal to verify the PHP version:
~~~~~~
php -v
~~~~~~~
7. Run the below command to install composer:
~~~~~
curl -sS https://getcomposer.org/installer | php
~~~~~~
Please check the below illustration:

8. Verify the composer version using the below command:
~~~~~
composer -V
~~~~~~
Please check the below illustration

9. To run composer commands, execute the below command.
~~~~~~
php composer.phar
~~~~~~~
Please check the below illustration:
