|

Install Composer on cPanel (Shared Hosting)

Composer is an amazing utility (dependency manager) to install frameworks and packages as it takes care of the dependencies and allows developers to easily install libraries. The installed libraries are pre-configured to depend on each other and the latest version of the library and its dependents are installed.

Most shared hosting servers will have Composer installed, but they may be on an older version. Or, even if the server doesn’t have it installed, it’s possible to deploy it anywhere as Composer itself is based on PHP.

To install Composer, here are the requirements:-
>> PHP 5.3.2 or above
>> Shell access (SSH)
>> cURL

Procedure

Step 1 | Setting up PHP environment

Log into your cPanel and open up the File Manager. You can install Composer wherever you want, but for the purposes of this tutorial, I’ll be installing it in a folder named composer in the home directory.

Once you’re inside the path where you want to install Composer, create/edit the php.ini file and add the following directives:

allow_url_fopen= On
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
suhosin.executor.include.whitelist = phar
detect_unicode = Off

Once you’ve added the above directives, make sure that there are no duplicates and save the file.

Step 2 | Installing Composer

Now that we’ve set up the PHP configuration for the folder, let’s install Composer. We can do this via the cPanel Terminal (i.e. if your host has it enabled), or you can use an SSH client. I’ll be installing it via the cPanel Terminal as well as with the open-source SSH client PuTTY.

Login to your hosting account via SSH and run the following command after you’ve entered the composer directory.

curl -sS https://getcomposer.org/installer | php -c php.ini

The above command has downloaded the latest version of Composer executable into the directory and now to run Composer, you can run the following command.

php composer.phar

Composer is now installed and you can use it to install frameworks such as CodeIgniter, Laravel, etc

5 2 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments