Installing composer prompts PHP Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages:

created at 10-17-2021 views: 128

Problem Description

#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

solution

# Download certificate http://curl.haxx.se/ca/cacert.pem
wget http://curl.haxx.se/ca/cacert.pem
# Or use the web page to download and upload to linux
mkdir -p /usr/local/openssl/ssl/certs/
mv cacert.pem /usr/local/openssl/ssl/certs/cacert.pem

Modify php.ini

;openssl.capath=
openssl.cafile=/usr/local/openssl/ssl/certs/cacert.pem

problem solved

Reinstall composer

created at:10-17-2021
edited at: 10-17-2021: