Install Composer on Ubuntu

I am trying to install composer with the command:

sudo curl -s https://getcomposer.org/installer | php

And I am getting this error:

All settings correct for using Composer
Downloading...
Download failed: failed to open stream: Permission denied
Downloading...
Download failed: failed to open stream: Permission denied
Downloading...
Download failed: failed to open stream: Permission denied
The download failed repeatedly, aborting.

I don't know why? Do you have an idea? I tryed to google it but nothing.


Your curl command is running as root (via sudo) but your php command is not. Try moving your sudo between the pipe ("|") and 'php' (assuming you want your installer to run as root in the first place...).