安装Composer报错error:14090086:SSL routines:ssl3_get_server_certificate解决方法

作者: 温新

分类: 【PHP基础】

阅读: 6203

时间: 2022-02-12 12:33:21

CentOS7安装Compoer报如下错误:

php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
PHP Warning:  copy(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in Command line code on line 1
PHP Warning:  copy(): Failed to enable crypto in Command line code on line 1
PHP Warning:  copy(https://install.phpcomposer.com/installer): failed to open stream: operation failed in Command line code on line 1

或者执行php composer-setup.php 报如下错误:

php composer-setup.php 
All settings correct for using Composer
Downloading...
The "https://install.phpcomposer.com/versions" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
Retrying...
The "https://install.phpcomposer.com/versions" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
Retrying...
The "https://install.phpcomposer.com/versions" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
The download failed repeatedly, aborting

解决方法:

进行如下安装就可以解决了。

yum install -y ca-certificates

我的使用的系统中,安装 ca-certificates就解决了。

因此,下面的方法我是没有测试的。

如果上述安装还没有解决,请继续操作:

下载证书http://curl.haxx.se/ca/cacert.pem 
wget http://curl.haxx.se/ca/cacert.pem
或者使用网页下载再上传至linux
mkdir -p /usr/local/openssl/ssl/certs/
mv cacert.pem /usr/local/openssl/ssl/certs/cacert.pem

修改php.ini

;openssl.capath=
openssl.cafile=/usr/local/openssl/ssl/certs/cacert.pem
请登录后再评论