I’ve had a few people tell me this has come in handy:

#####In console

1
2
3
4
5
6
7
$ cd ~
$ sudo curl -sS https://getcomposer.org/installer | sudo php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer
 
then you can run 
$ sudo composer install