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?
TLDR;
As described on the Composer website:
Manual Method
I found an easier way to globally install composer than the manual proscribed in the github
readme.md
. It's actually on the getcomposer.org website:And if you're even more lazy, like me, you can create an alias:
This way you can invoke composer with just
composer
Don't add
php
in the beginning. Just callcomposer.phar
.Actually, getcomposer.org now recommends a simpler method:
Now you can just use
composer
without bothering with an alias or a separatesh
script.Another alternative to get a nice
composer
command instead ofcomposer.phar
:for easier execution I created /usr/local/bin/composer with content:
dont forget about
sudo chmod +x /usr/local/bin/composer.phar
Below are the steps to be followed to install composer globally: 1. Before installing Composer, make sure our server has all dependencies installed.
1st, update the package manager cache by running:
2. Now, let's install the dependencies. We'll need
Everything can be installed with the following command:
3. Composer installation with a single command:
4. This will download and install Composer as a system-wide command named composer, under /usr/local/bin. The output should look like this:
Output:
Use it: php /usr/local/bin/composer
5. To test your installation, run:
Output:
I have made a simple bash script that automatically installs composer for current user/all users, you can one of the following commands in your terminal to use bash script.
Current User
All Users
Check out the Gist
This might work for you. Note that
sudo
is used two times here.