Windows下安装composer出错的原因

需要安装Composer,安装地址:https://pkg.phpcomposer.com/#how-to-install-composer

1.执行了代码1.执行了代码

php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"

2.出错如下:

Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify faile
d in Command line code on line 1

Warning: copy(): Failed to enable crypto in Command line code on line 1

Warning: copy(https://install.phpcomposer.com/installer): failed to open stream:
 operation failed in Command line code on line 1

3.解决的方法

a.原因是在于没有CA证书导致的,下载CA证书:https://curl.haxx.se/docs/caextract.html

b.修改PHP.ini,指定下载的cacert.pem路径

openssl.cafile=D:\server\composer\certs\cacert.pem