Composer provides an installer script written in PHP. We’ll download it, verify that it’s not corrupted, and then use it to install Composer.
Make sure you’re in your home directory, then retrieve the installer using curl:
cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
Create hash Key
HASH=`curl -sS https://composer.github.io/installer.sig`
verify it using
echo $HASH
it will return your key
Now execute the following PHP code, as provided in the Composer download page, to verify that the installation script is safe to run:
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Output must be
Installer verified
than run below command to install composer globally,
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
check composer installation
composer
if youll get path error than set alias
alias composer='/usr/local/bin/composer' Follow the below link for more clarificationshttps://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-20-04
Comments
Post a Comment