Install Composer On Shared Hosting Cpanel - FreeCodeBlog

Last updated: Jan 22, 2022

Want to install PHP Composer package files on shared hosting cpanel? To use php, laravel scripts in shared hosting cpanel you need to install composer in cpanel. We can easily install composer on shared hosting cpanel. All we need to do is use the cpanel terminal, php, php.ini file to install Composer on shared hosting. I hope you have a shared hosting cpanel before. Ok Now let's start to install composer on shared hosting cpanel.

 

Install Composer On Shared Hosting Cpanel
Install Composer On Shared Hosting Cpanel

 

What is composer?

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on, and it will manage (install/update) them for you. Composer is not a package manager in the same sense as Yum or Apt are. Yes, it deals with 'packages' or libraries, but it manages them on a per-project basis, installing them in a directory (e.g., vendor) inside your project. By default, it will never install anything globally. Thus, it is a dependency manager.

 

Why need composer on cpanel?

Are you a PHP programmer and want to install composer files on shared hosting cpanel?. As a PHP programmer, you need to install Composer on a shared hosting cpanel to install or update Composer files and vendor folders. For more information you can read why do I need a composer in cpanel? question.

 

Step To Install Composer On Shared Hosting Cpanel.

  1. Login Cpanel.
  2. Change PHP Version.
  3. Open File Manager.
  4. Create and edit php.ini file.
  5. Open Terminal.
  6. Install Composer.

 

1. Login  Cpanel.

First you need to login in cpanel dashboard to install composer. We can easily login cpanel dashboard using username and password to install composer on shared hosting cpanel. So let's login to cpanel.

 

2. Change PHP Version.

You need to check php version on cpanel before start to install composer. You will see “Select PHP Version” after login on shared hosting cpanel. Click on the “Select PHP Version” to go “PHP Sector” page. Change PHP Version 5.5+ to 7.4+ from PHP version change page to install composer on shared hosting cpanel because composer required “PHP 5.5+”. Read how to check and change PHP version on shared hosting cpanel tutorial for more information.

 

3. Open File Manager.

Now you need to open cpanel file manager to create a php.ini file and composer installation. So open file manager by clicking on “file manager” from cpanel dashboard.

 

4. Create and edit php.ini file.

Did you open cpanel file manager? Yes!. Ok now you need to create php.ini file in public_html folder. You can create php.ini files in other folders but I suggest you create php.ini file in public_html folder. PHP.ini file is most important to install composer on cpanel so don't forget to create php.ini file into public_html folder. Click on the file button from navbar to create a new “php.ini” file into “public_html” folder.

     

php.ini

 

If you have a created PHP file in a public_html folder, edit it. Write and save change below information into php.ini file.

 

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

 

5. Open Terminal.

Did you create and edit the php.ini file? Now you need to open terminal from cpanel dashboard to install composer on shared hosting cpanel. Actually I will use cpanel terminal to install composer. So cpanel is important to install composer in shared hosting. 

 

Let's check current php version again using cpanel terminal before start to install composer on cpanel. Run php --version command on cpanel terminal interface to see current php version. I suggest you use the latest version of php in cpanel shared hosting.

 

php - v

 

7. Install Composer.

Now you are ready to install composer on shared hosting cpanel. After clicking on the terminal you will see the terminal interface. Now you need to go to your folder where you want to install Composer. For example, I want to install composer into "public_html" folder. So I need to go “public_html” folder from terminal interface. 

    

cd public_html

 

Wait a minute, want to install composer in subfolder? You can also install composer in subfolder of public_html. Just you need to go subfolder to install composer on cpanel. If you want to know where exactly you need to install composer on cpanel then don't forget to read where can i install composer in cpanel? question.

            

cd public_html/subfolder

 

Now let's run composer programming code to install composer on shared hosting cpanel. Please make sure that you have a created php.ini file in public_html folder. This command will install latest version of composer into your selected folder.

      

php -r "readfile('https://getcomposer.org/installer');" | php -c php.ini

 

Want to check if Composer is installed in cpanel? You need to run composer command to check composer installed or not on shared hosting cpanel.

     

composer

 

Not sure if you have Composer installed on the shared hosting cpanel? You will get a composer file in where you installed composer. You can see a composer folder in file manager root folder. If composer.phar file not working to install composer package files then don't forget to read why isn't composer.phar working on cpanel? question.

  

composer.phar

 

Want to use Composer now installed? After successfully installed composer you can easily use composer like this.

  

php composer.phar

 

Want to install Composer package files using cpanel composer now installed? Use cpanel composer to install "composer.json" files.

  

php composer.phar install

 

You can also use the shared hosting cpanel composer to install any single composer package file. Use composer require command to install any composer package file.

   

php composer.phar require pacakge/name

 

Okay so this is for today. See you again next tutorials. Thanks

Post Tags
Post Writer
masum7323
Masum Biswas (@masum7323)

My name is Masum Biswas. I'm a full stack developer. I live in Bangladesh and I love to write tutorials and tools that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, MySQL, VueJS, Tailwind CSS and Bootstrap from the early stage.

Follow Me On
Related Posts
How To Deploy Cpanel Ssh Key On Github Private Repository

Want to connect GitHub private repository to Cpanel git version control? Yes. Then you must need to deploy created cpanel ssh key on created GitHub... Read More

Create A Email Account From Cpanel For Laravel Email Verification

Want to create an email account from cpanel? Yes!. Okay But why? Because I want to verify laravel email verification. Okay If you want to send a la... Read More

Laravel Project Upload To Cpanel Using Private Github Repository

Private GitHub repository for laravel uploading! Yes, You can easily upload your laravel project to shared hosting cpanel using private GitHub... Read More

The Best Way To Upload Laravel Projects To Shared Hosting Cpanel

We can easily upload laravel projects to shared hosting (cpanel) using git version control. Git version control (Private Repository) is the best wa... Read More

How To Create Repository On Cpanel

Cpanel git version control! Yes. You should create repository on cpanel to use git version on your website. Want to connect GitHub repositories wit... Read More