How to Install Composer in CWP/Vesta/Cpanel/Plesk – CentOS/Ubuntu

by Sandeep B.

In this tutorial we’ll install composer quickly and learn how to update composer and use different php version paths with 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 can be installed in your server quickly and its very easy to install :-

Installation of Composer

Switch into the /usr/local/bin directory.

cd /usr/local/bin

Download and installing Stable version of Composer by using cURL :

curl -o composer

Fix the permission also this will create global access to composer i.e. user having shell access can execute composer :

chmod 755 /usr/local/bin/composer

For ubuntu/debian you need to follow this steps :

ln -s /usr/local/bin/composer /usr/bin/composer

That’s it composer is successfully installed.

you can now use composer command in shell to execute.

Check Composer version :

composer -V

eg. :

[root@server bin]# composer -V
Do not run Composer as root/super user! See for details
Continue as root/super user [yes]? yes
Composer version 2.0.7 2020-11-13 17:31:06

Update composer upon new version releases :

to update composer you just need to run this command :

composer self-update

**it will update to stable latest version

Run different php version with the composer :

you need to user the full path for php bin and composer path with the composer sub command we use “install” command here as eg:

/path/to/php-bin /usr/local/bin/composer install

For CWP run composer as php selector and php-fpm selector :

For php selector :

/opt/alt/php56/usr/bin/php /usr/local/bin/composer install
/opt/alt/php70/usr/bin/php /usr/local/bin/composer install
/opt/alt/php71/usr/bin/php /usr/local/bin/composer install
/opt/alt/php72/usr/bin/php /usr/local/bin/composer install
/opt/alt/php73/usr/bin/php /usr/local/bin/composer install

For php-fpm selector :

/opt/alt/php-fpm56/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm70/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm71/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm72/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm73/usr/bin/php /usr/local/bin/composer install

For Cpanel/WHM :

ea-php71 /usr/local/bin/composer install
ea-php72 /usr/local/bin/composer install
ea-php73 /usr/local/bin/composer install

For other panel’s multi php refer to the official docs and paths for the php bin file

Troubleshoot :

if you get below error then php is not installed in default location you need to specify the path for php bin

/usr/bin/env: ‘php’: No such file or directory

If this post helps you in any way please consider a donation

Donate with PayPal :


You may also like


Vasile July 21, 2020 - 4:56 pm

Hi when i run “/opt/alt/php-fpm73/usr/bin/php /usr/local/bin/composer install” on cwp it says there is no composer.json in root directory.

Sandeep B. July 21, 2020 - 7:24 pm

ensure you’re in correct root dir where composer.json is located for your script.

Vasile July 22, 2020 - 6:34 am

As you can see in this image when i run composer global about it shows me that composer directory in at “/root/.config/composer” where is also my composer.json file but i still get that message about composer.json not being in /root

Sandeep B. July 22, 2020 - 6:44 am

okay I see you need to skip that step since you’re not running different php versions and this steps are only for script installation not for the composer installation.


Leave a Comment