How to Install Composer in CWP/Vesta/Cpanel/Plesk – CentOS/Ubuntu
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
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 https://getcomposer.org/root 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
/opt/alt/php74/usr/bin/php /usr/local/bin/composer install
/opt/alt/php80/usr/bin/php /usr/local/bin/composer install
/opt/alt/php81/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
/opt/alt/php-fpm74/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm80/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm81/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
ea-php74 /usr/local/bin/composer install
ea-php80 /usr/local/bin/composer install
ea-php81 /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
Posted on: October 21, 2024, by : Julian's | 23 views