Install Composer in Ubuntu


Rather than adding a composer.phar file to each project it can be easier to install composer to your linux distribution’s bin folder.

#ensure php cli is installed
apt-get install php5-cli
 
cd /usr/bin
#install composer, notice the sudo to allow us to write to /usr/bin
php -r "readfile('https://getcomposer.org/installer');" | sudo php
 
#create a composer file that calls the composer.phar and add execute permission to it
sudo bash -c 'echo -e "#!/bin/bash\nphp /usr/bin/composer.phar "$@" > composer'
sudo chmod +x composer
  1. #1 by Thomas on July 24, 2015 - 1:59 am

    it seems to have a ” problem in your script.
    Perhaps this could be a fix:
    sudo bash -c ‘echo -e “#!/bin/bash\nphp /usr/bin/composer.phar \”$@\”” > composer’

    Thanks for sharing this!
    Thomas.

(will not be published)