dongpo9071
dongpo9071
2018-01-13 16:37

Composer安装失败

已采纳

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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • drmticpet66231422 drmticpet66231422 3年前

    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.

    点赞 评论 复制链接分享
  • dongye9820 dongye9820 2年前

    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

    点赞 评论 复制链接分享
  • douyue3800 douyue3800 3年前

    It is caused by my kaspersky internet security I fixed it by disabling KIS temporary

    you can give it a try.

    点赞 评论 复制链接分享
  • dongyuan6949 dongyuan6949 3年前

    It looks like a misconfiguration of PHP/openssl on your host.

    My workstation is Ubuntu 16.04.3, php 7.0.22 and openssl-1.0.2g - the installer worked fine.

    Try with TLS disabled:

    curl -sS https://getcomposer.org/installer | php -- --disable-tls
    
    点赞 评论 复制链接分享
  • dongmu5815 dongmu5815 2年前

    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"

    点赞 评论 复制链接分享

相关推荐