Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I followed composer manual (global installation of composer (manual)) to install composer on Ubuntu.

$ ll /usr/local/bin/
total 4760
drwxr-xr-x  2 root root    4096 2012-03-29 08:29 ./
drwxr-xr-x 10 root root    4096 2011-04-26 00:50 ../
-rwxr-xr-x  1 root root  410324 2012-03-29 08:28 composer.phar

Other scripts from /usr/local/bin/ works, but composer gives:

$php composer.phar update Could not open input file: composer.phar

It works only if I enter absolute path to composer.phar. How to fix this?

share|improve this question
up vote 23 down vote accepted

Don't add php in the beginning. Just call composer.phar.

share|improve this answer
It works, thanks. Explanation would be great, I'm curious. Thanks again. – umpirsky Jun 19 '12 at 19:18
It works because composer is already an executable (it has u+x rights by default). So, no need to execute php, because shell will do it anyway. – netvision73 Jan 9 '14 at 10:36
And there is a special code on the first line of composer.phar, #!/usr/bin/env php which tells ubuntu that the file is a php file and should be run with the php program. – T0xicCode Feb 8 '14 at 19:36


As described on the Composer website:

curl -sS | php
sudo mv composer.phar /usr/local/bin/composer

Manual Method

I found an easier way to globally install composer than the manual proscribed in the github It's actually on the website:

curl -s | php
sudo mv composer.phar /usr/local/bin/

And if you're even more lazy, like me, you can create an alias:

alias composer='/usr/local/bin/composer.phar'

This way you can invoke composer with just composer

share|improve this answer
Nice. The alias is a sweet touch for obsessive compulsives too. Typing in file extensions? Pfeh! That's for chumps – eggonlegs Aug 15 '12 at 14:00
Laziness, mother of creativity. Last update is the best ! – Pierre de LESPINAY Oct 21 '13 at 7:27
when I run $ sudo mv composer.phar /usr/local/bin/composer and then try to type $ composer I get the error: bash: /usr/local/bin/composer: Permission denied How can I change these permissions? – Connor Leech Jan 13 '14 at 9:19
@ConnorLeech You can run chmod +x /usr/local/bin/composer – Chibueze Opata Mar 20 '14 at 22:23
@KimStacks I think it makes sense to keep it there context. – chrisjlee Mar 28 '14 at 3:39

Actually, now recommends a simpler method:

$ curl -sS | php
$ sudo mv composer.phar /usr/local/bin/composer

Now you can just use composer without bothering with an alias or a separate sh script.

share|improve this answer
This is correct. – Jack Franzen May 5 '15 at 19:09

Another alternative to get a nice composer command instead of composer.phar:

$ curl -sS | php -- --install-dir=/usr/local/bin
$ ln -s /usr/local/bin/composer.phar /usr/local/bin/composer
share|improve this answer
You can even use --filename=composer to save the symlink part :) – magnetik May 15 '14 at 14:50

for easier execution I created /usr/local/bin/composer with content:

exec /usr/local/bin/composer.phar "$@"

dont forget about sudo chmod +x /usr/local/bin/composer.phar

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.