23

I am trying running laravel in my computer, but I have some difficults to install this resource in my machine, follow below a little bit of error in terminal of linux

All settings correct for using Composer
Downloading...
Could not create file /var/www/html/composer.phar: fopen(/var/www/html/composer.phar): failed to open stream: Permission denied
Download failed: fopen(/var/www/html/composer.phar): failed to open stream: Permission denied fwrite() expects parameter 1 to be resource, boolean given
Downloading...
Could not create file /var/www/html/composer.phar: fopen(/var/www/html/composer.phar): failed to open stream: Permission denied
Download failed: fopen(/var/www/html/composer.phar): failed to open stream: Permission denied
fwrite() expects parameter 1 to be resource, boolean given
Downloading...
Could not create file /var/www/html/composer.phar: fopen(/var/www/html/composer.phar): failed to open stream: Permission denied
Download failed: fopen(/var/www/html/composer.phar): failed to open stream: Permission denied
fwrite() expects parameter 1 to be resource, boolean given
The download failed repeatedly, aborting.
alexander@alexander:/var/www/html$

7
  • use your commands as super-admin.. Commented Jun 22, 2014 at 1:19
  • I use the before the command sudo, but the code returns the same problem Commented Jun 22, 2014 at 1:21
  • Did you use sudo su before run the command? Commented Jun 22, 2014 at 1:22
  • alexander@alexander:/var/www/html$ sudo su curl -sS getcomposer.org/installer | php Nenhuma entrada de passwd para usuário 'curl' alexander@alexander:/var/www/html$ Commented Jun 22, 2014 at 1:28
  • 3
    When you pipe you need to add sudo to both commands. So the second part after | should also be sudo Commented Jun 22, 2014 at 1:36

4 Answers 4

106

I used sudo as follows:

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks you! I wasn't aware of the 2nd "sudo". This should be marked as correct answer.
6

Permission problem troubleshooting:

Sudo

As g-newa suggested, often the issue lies in you not using sudo which allows you to run as root. Please note that just because you put two commands on the same line doesn't mean that you have one command. When you pipe - aka sudo find -name foo | xargs rm -rf - you actually have two commands: find, and xargs. The above will not work. In fact, so long as you have privileges to find or, in your case, curl, in a folder, you don't even need sudo there. Instead, find -name foo | sudo xargs rm -rf would be far more likely to work without a hitch. For cases where sudo is needed for both commands, simply add it to both commands.

Permissions

Although less commonly an issue, there are times where a file is on such lock-down that not even a sudoer can touch it. In this instance make sure you understand what the file is and why it is so locked down. Chances are good you should not mess with it. If, however, the settings are restricted as an accident, you can change them to allow root manipulation.

ls -la

Checks permissions.

sudo chmod 700 <filename>

Changes permissions to allow for sudo.

Comments

2

you should download the file composer.phar in a directroy with permissions. If you don't want, you should run with sudo

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

Comments

1

Just follow three simple steps as it describer here You should run all commands trough CLI (command line interface, same Terminal)

  1. update package cache: sudo apt-get update
  2. install dependences: sudo apt-get install curl php5-cli git
  3. download and install composer: curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
  4. to test composer just run composer

Voila! Everything is done.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.