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 https://getcomposer.org/composer-stable.phar -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

That’s it composer is successfully installed.

you can now use composer command in shell to execute.

Check Composer version :

composer -V

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

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

Donate with PayPal :

md-donate

Donate with Paytm :

md-donate

You may also like

Leave a Comment