1

I am getting this sort of error while downloading composer.

php composer-setup.php
All settings correct for using Composer
PHP Warning:  file_put_contents(/home/vasu/.composer/keys.dev.pub): failed to open stream: Permission denied in /home/vasu/composer-setup.php on line 468
PHP Warning:  file_put_contents(/home/vasu/.composer/keys.tags.pub): failed to open stream: Permission denied in /home/vasu/composer-setup.php on line 485
Downloading 1.2.0...
PHP Warning:  openssl_verify(): supplied key param cannot be coerced into a public key in /home/vasu/composer-setup.php on line 576
PHP Warning:  openssl_free_key() expects parameter 1 to be resource, boolean given in /home/vasu/composer-setup.php on line 577
Signature mismatch, could not verify the phar file integrity
karel
  • 122,292
  • 133
  • 301
  • 332

1 Answers1

3

Easy way

Try the easy way first. The hard way was included in this answer because of the error messages mentioned in the comments.

sudo mkdir -p /usr/local/bin  
sudo apt-get install curl
curl -sS https://getcomposer.org/installer | php   
sudo mv composer.phar /usr/local/bin/composer   

In Ubuntu 16.04 and later composer can be installed from the default Ubuntu repositories. Open the terminal and type:

sudo apt install composer  

Hard way

First check if /usr/local/bin/ exists, and if not make the /usr/local/bin/ directory.

sudo mkdir -p /usr/local/bin

If /usr/local/bin/ already exists, the above command will do nothing except return this message:

mkdir: cannot create directory ‘/usr/local/bin’: File exists

Run these commands:

sudo chmod -R 755 /usr/local/bin/  
cd /usr/local/bin/
ls # list the old composer file(s)
sudo rm <old-composer-files> # delete the old composer file(s)
sudo apt-get install curl
curl -sS https://getcomposer.org/installer | php   
sudo mv composer.phar /usr/local/bin/composer  

Then if you type composer in the terminal it will be accessible globally in your system.

karel
  • 122,292
  • 133
  • 301
  • 332