Devenez Revendeur et gagnez de l'argent en revendant de l'hébergement web. En savoir plus

Tous les articles
Blog English

Master Composer on cPanel Without Root Access: Quick Guide

KEN CODE7 février 20262 min de lecture

Introduction

If you manage PHP projects on a cPanel server, you may have noticed that Composer, the PHP dependency manager, is not installed by default. This guide shows you how to check if it is installed, install it locally, and use it effectively.

What is Composer?

Composer is a dependency management tool for PHP. It allows you to:

  • Automatically install the libraries required for your projects
  • Easily manage package updates
  • Ensure compatibility between different PHP versions and packages

Check if Composer is Installed on cPanel

Connect via SSH and type:

which composer

Result:

  • If installed: shows the path (e.g. /home/youruser/composer)
  • If empty: Composer needs to be installed manually

Install Composer Locally on cPanel

  1. Navigate to your home directory:
cd /home/youruser
  1. Download the installation script:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  1. Install Composer:
php composer-setup.php --install-dir=/home/youruser --filename=composer
  1. Remove the script:
php -r "unlink('composer-setup.php');"
  1. Verify the installation:
/home/youruser/composer --version

Add Composer to the PATH

Current session

export PATH=/home/youruser:$PATH

Permanent

  1. Edit the .bashrc file:
nano ~/.bashrc
  1. Add at the end:
export PATH=/home/youruser:$PATH
  1. Reload the file:
source ~/.bashrc

Use Composer in Your PHP Projects

Install dependencies:

cd ~/my-project
composer install

Update packages:

composer update

Conclusion

Installing Composer on cPanel is simple and does not require root access. Once installed locally and added to your PATH, you can manage PHP dependencies as if Composer were installed globally.

For more information, see the official Composer documentation.