Composer安装失败。

5

我正在尝试在使用PHP版本5.6.*Ubuntu 16.04中安装composer。

我使用了命令:curl -sS https://getcomposer.org/installer | php。但是它给了我以下错误:

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.

我之前没有安装composer。

这个回答解决了你的问题吗?由于证书问题无法安装Composer - Vic Seedoubleyew
6个回答

6
打开终端并运行 php -r "var_dump(openssl_get_cert_locations());" 注意default_cert_file的位置。它可能会显示为\usr\local\ssl\cert.pem。请确保该文件存在。如果不存在,请从https://curl.haxx.se/ca/cacert.pem下载cacert.pem文件,并将其放置在最好是/usr/local/ssl的某个地方。
现在您有一个名为usr/local/ssl/cacert.pem的文件
打开php.ini并添加文件的位置openssl.cafile=cacert.pem 安装composer 运行composer config --global cafile "/usr/local/ssl/cacert.pem"

6

我通过下载 https://curl.haxx.se/ca/cacert.pem ,并在我的 etc/php/5.6/cli/php.inietc/php/5.6/apache2/php.ini 中提供它的路径来解决了这个问题。

然后运行 sudo service apache2 restart && sudo apt install composer 就能正常工作了。


3

看起来您的主机上PHP/openssl配置错误。

我的工作站是Ubuntu 16.04.3,php 7.0.22和openssl-1.0.2g - 安装程序运行良好。

尝试禁用TLS:

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

通过禁用TLS来“修复”这个问题绝对不符合发帖者的问题精神... - scott8035

3

在使用 Laravel Homestead 时,我不小心清空了此文件的内容:/etc/ssl/certs/ca-certificates.crt

以下操作解决了我的问题:

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

感谢https://stackoverflow.com/a/53351370/470749提供的帮助。


1
谢谢,它对我解决了问题。 在运行“sudo apt-get install ca-certificates”之前, 请先运行“sudo apt-get update”。 - Ramon Veloso

0

这是由我的卡巴斯基互联网安全软件引起的问题,我通过暂时禁用KIS来解决它。

你可以试一试。


0
将导出代理从https改为http 打开终端
    echo $https_proxy
// Change export proxy from 
    https_proxy=https://192.168.0.10:8080/
// to 
   https_proxy=http://192.168.0.10:8080/

命令行: https_proxy=http://192.168.0.10:8080/


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接