centos系统中安装composer报:SSL operation failed with code错误解决方法
这是一个服务器上找不到这个pem文件的报错,需要下载证书,以下是完整报错信息:
[[email protected]_6_184_centos composer]# 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
进入解决方法步骤:
1.先到官网下载证书
https://curl.se/docs/caextract.html
2.进入后
点击醒目的cacert.pem链接下载,得到cacert.pem,上传至服务器。
3.编辑php.ini
php --ini
查看php.ini真实路径)
openssl.cafile=/usr/local/openssl/ssl/certs/cacert.pem
4.重启 service php-fpm restart
再按照composer官方安装文档安装就可以了
下面是composer安装过程:
*全局安装
[[email protected]_6_184_centos certs]# cd /usr/local/composer/
[[email protected]_6_184_centos composer]# ll
total 0
[[email protected]_6_184_centos composer]# php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
[[email protected]_6_184_centos composer]# ll
total 64
-rw-r--r-- 1 root root 58148 Nov 17 18:29 composer-setup.php
[[email protected]_6_184_centos composer]# php composer-setup.php
All settings correct for using Composer
Downloading...
Composer (version 2.2.18) successfully installed to: /usr/local/composer/composer.phar
Use it: php composer.phar
[[email protected]_6_184_centos composer]# ls
composer.phar composer-setup.php
[[email protected]_6_184_centos composer]# php -r "unlink('composer-setup.php');"
[[email protected]_6_184_centos composer]# ls
composer.phar
[[email protected]_6_184_centos composer]# mv composer.phar /usr/local/bin/composer
[[email protected]_6_184_centos composer]# composer --version
Composer version 2.2.18 2022-08-20 11:33:38
[[email protected]_6_184_centos composer]# composer
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 2.2.18 2022-08-20 11:33:38
出现以上界面就说明安装完成了
相关文章