Skip to main content

How to Install Composer in cPanel

Updated over 2 weeks ago

Composer makes PHP package management easier. Instead of manually downloading dependencies, you can use Composer to automatically install everything from Packagist. You just need to search for the package and run it with the proper command.


Step 1: Installing Composer in cPanel

1. Access the terminal
From your cPanel dashboard, scroll down to the Advanced section and click on Terminal to open a command console.


2. Go to the temporary directory
Run the following command to move to the temporary folder:

cd /tmp


3. Download the Composer installer
Install Composer using:

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


4. Move Composer to an accessible path

  • Once the composer.phar file is downloaded, it’s best to move it to a directory accessible from anywhere.
    Run:

mkdir ~/bin
  • Move the Composer file to that new directory and rename it:

mv composer.phar ~/bin/composer
  • Now give it execution permissions:

chmod +x ~/bin/composer

5. Add Composer to the system PATH
To use Composer from any location, add its path to the environment with:

echo "export PATH=\$HOME/bin:\$PATH" >> ~/.bash_profile

6. Reload the configuration file
Apply the changes by running:

source ~/.bash_profile


7. Verify the installation

Check that Composer is correctly installed with:

which composer

You can also verify the installed version with:

composer --version


⚠️ If you see a warning saying “Do not run Composer as root/super user”, you can ignore it in this context.

✅ Done! Composer is now installed and ready to use in your cPanel environment.

Did this answer your question?