Created
June 30, 2024 14:35
-
-
Save naranyala/3968099d8d86cd29982997e8e7f55377 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Update package list | |
echo "Updating package list..." | |
sudo apt update | |
# Install PHP | |
echo "Installing PHP..." | |
sudo apt install -y php8.0 | |
# Verify PHP installation | |
echo "Verifying PHP installation..." | |
php -v | |
# Download Composer installer | |
echo "Downloading Composer installer..." | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
# Verify the installer (Note: Change the hash with the latest from Composer website) | |
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) | |
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") | |
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] | |
then | |
echo "ERROR: Invalid installer signature" | |
rm composer-setup.php | |
exit 1 | |
fi | |
# Install Composer globally | |
echo "Installing Composer..." | |
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer | |
# Remove the installer | |
echo "Removing installer..." | |
php -r "unlink('composer-setup.php');" | |
# Verify Composer installation | |
echo "Verifying Composer installation..." | |
composer --version | |
echo "Installation completed successfully." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment