Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer install failed

I'm trying to install composer in my Ubuntu 16.04 with PHP version 5.6.*.

I used:curl -sS https://getcomposer.org/installer | php. But it is giving me error as follows:

All settings correct for using Composer
Downloading...
The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: Connection refused
Retrying...
The "https://getcomposer.org/versions" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
Retrying...
The "https://getcomposer.org/versions" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
The download failed repeatedly, aborting.

I do not have composer installed previously.

like image 373
P S Avatar asked Jan 13 '18 16:01

P S


People also ask

Why is composer not installing?

Why is composer not installing? Make sure you have no problems with your setup by running the installer's checks via curl -sS https://getcomposer.org/installer | php — –check . Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer.

How install composer install?

Step 1: Navigate to the official composer website. Step 2: Then click on the Download button. Step 3: Then click on the Composer-Setup.exe & download the file. Step 4: Then click on “Install for all users”.

How do you solve a composer error?

To solve the Memory exhausted issue, you can try running composer with an Unlimited memory flag like this: php -d memory_limit=-1 /usr/local/bin/composer [COMMAND] or php -d memory_limit=-1 composer. phar [COMMAND] when using a local composer. If that doesn't help, you can upgrade your hosting plan.


3 Answers

I solved the issue by downloading https://curl.haxx.se/ca/cacert.pem and giving it's path in my etc/php/5.6/cli/php.ini and etc/php/5.6/apache2/php.ini.

Then after running sudo service apache2 restart && sudo apt install composer just worked fine.

like image 80
P S Avatar answered Sep 30 '22 10:09

P S


Open terminal and run php -r "var_dump(openssl_get_cert_locations());"

Note the location of default_cert_file. It might say \usr\local\ssl\cert.pem Verify that that file exists. If not, download the cacert.pem file from https://curl.haxx.se/ca/cacert.pem and place it in somewhere preferably in /usr/local/ssl

You now have a file is usr/local/ssl/cacert.pem

Open your php.ini and add the location of the file openssl.cafile=cacert.pem

Install composer

Run composer config --global cafile "/usr/local/ssl/cacert.pem"

like image 27
jmuchiri Avatar answered Sep 30 '22 08:09

jmuchiri


I experienced this problem while using Laravel Homestead after I’d accidentally emptied the contents of this file: /etc/ssl/certs/ca-certificates.crt

What fixed it for me was:

sudo apt-get purge ca-certificates 
sudo apt-get install ca-certificates

Thanks to https://stackoverflow.com/a/53351370/470749

like image 27
Ryan Avatar answered Sep 30 '22 08:09

Ryan