Skip to content

Instantly share code, notes, and snippets.

@MCMXCIII
Forked from hasanbayatme/README.md
Created May 9, 2019 12:29
Show Gist options
  • Save MCMXCIII/00001f6221771b6f678ee4f7426f92a7 to your computer and use it in GitHub Desktop.
Save MCMXCIII/00001f6221771b6f678ee4f7426f92a7 to your computer and use it in GitHub Desktop.
A Simple Bash Script for Installing Composer on Ubuntu Locally (current user) and Globally (all users).

Installation

Install composer locally (current user only):

wget -O - https://gist.github.com/EmpireWorld/1dd5f59566e186907f99dc16badc382a/raw/install-composer-local.sh | bash

Install composer globally (all users):

wget -O - https://gist.github.com/EmpireWorld/1dd5f59566e186907f99dc16badc382a/raw/install-composer-global.sh | bash

Made with ❤️ by Bayat

#!/bin/bash
########################
# Written by Hasan Bayat
# Installs composer for all users.
# License MIT @ Bayat
########################
# Check if composer currently installed
if hash composer; then
echo "Composer Already Installed"
echo "You can find it at $(type -p composer)"
exit
fi
# Update package index
sudo apt update
# Make sure php is installed
sudo apt install php php-cli
# Download latest composer snapshot and run it by php
sudo wget https://getcomposer.org/composer.phar
# Move composer to /bin/composer
sudo mv composer.phar /bin/composer
echo "Composer Installed Globally Successfully"
echo "Composer Installed at $(type -p composer)"
echo "You can always find it by calling `type -p composer`"
#!/bin/bash
########################
# Written by Hasan Bayat
# Installs composer for current user only.
# License MIT @ Bayat
########################
# Check if composer currently installed
if hash composer; then
echo "Composer Already Installed"
echo "You can find it at $(type -p composer)"
exit
fi
# Update package index
sudo apt update
# Make sure php is installed
sudo apt install php php-cli
# Download latest composer snapshot and run it by php
sudo wget https://getcomposer.org/composer.phar
# Move composer to /usr/local/bin/composer
sudo mv composer.phar /usr/local/bin/composer
echo "Composer Installed Locally Successfully"
echo "Composer Installed at $(type -p composer)"
echo "You can always find it by calling `type -p composer`"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment