!/bin/bash
Check wether composer installed or not:
if [ ! -x /usr/local/bin/composer ]; then
echo "INSTALLING composer"
Checks the current php version & Install the dependencies:
CURRENT=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d".")
echo "Y" | apt install curl php$CURRENT-cli php$CURRENT-mbstring git unzip
Change the path to tilde directory & Downloads the composer setup file:
cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
It gets SHA384 composer value:
HASH=$(curl https://composer.github.io/installer.sig | awk '{print $1}')
Preparing composer installation setup:
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installing Composer:
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Removes the downloaded setup file:
rm -rf ~/composer-setup.php
Message showing successfully installed:
echo "SUCESSFULLY INSTALLED composer"
During Initial check if composer installed already it shows message:
else
echo "ALREAY INSTALLED composer"
fi
Installation shell script for php-composer available in github repo
Top comments (0)