centos7 下安装composer失败

The "https://getcomposer.org/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
[root@10 src]# curl -sS https://getcomposer.org/installer | php
curl: (60) Peer's Certificate issuer is not recognized.
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

 Composer是PHP5.3版本以上的一个依赖管理工具。它允许你声明项目所依赖的代码库,它会在你的项目中为你安装他们。Composer不是一个包管理器,它涉及 "packages" 和 "libraries",但它在每个项目的基础上进行管理,在你项目的某个目录中(例如vendor)进行安装。默认情况下它不会在全局安装任何东西。因此,这仅仅是一个依赖管理。下面就介绍一下centos7如何安装Composer。

1.下载

确保系统环境中 可执行 php -v。

curl -sS https://getcomposer.org/installer | php

curl -ksS https://getcomposer.org/installer | php  # -k 参数跳过ssl检测

2.配置系统变量

mv composer.phar /usr/local/bin/composer 

3.更换镜像

composer config -g repo.packagist composer https://packagist.phpcomposer.com

4.查看

composer

出现下图,代表安装成功:

在以上方法失败的情况下,直接去官网下载composer.phar, 然后写个bat命令 php composer.phar %* 就行了.(亲测可行)

1.下载这个文件:https://getcomposer.org/composer.phar

mv composer.phar  /usr/local/bin/composer

2.给composer 最高权限

chmod -R 777 composer 

3.查看composer版本

composer --version  或直接 composer

(3)验证 Composer是否安装成功
完成上面步骤的 安装后 , 在命令行中输入 以下命令 : composer --version

若执行结果如下所 示 ,则说 明安装成功 。

$ composer --version

Composer version 1.5.2 2017一09-11 16:59:25

(4)配置 Packagist全量中国镜像

为了加快访问速度 , 安装完毕后需要配置 Composer 全量中国镜像。镜像服务器在国 内,可以提高访问速度, 在检索和使用时也更加便捷。

官方提供了两种方式 ,可以任选一种进行更新 , 在这里只需要在命令行中输入以下命令 :

composer config -g repo.packagist composer https://packagist.phpcomposer.com

若没有任何返回提示 ,则说明已经配置成功 。

赞赏码

非学,无以致疑;非问,无以广识

原文地址:https://www.cnblogs.com/lxwphp/p/15847725.html