Composer 官网:https://getcomposer.org/,首先获取安装包:

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

返回:

All settings correct for using Composer
Downloading...

Composer (version 1.5.2) successfully installed to: /root/composer.phar
Use it: php composer.phar

用 ls 命令你可以看到刚才操作的目录里出现了 composer.phar 这个文件,使用 php composer.phar 可以操作 composer,我们把它放到系统环境变量里便于调用,例如:

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

移动以后,我把它重命名成了 composer,现在输入:

composer --help

出现如下类似提示和图案表示 Composer 已经安装成功。

Do not run Composer as root/super user! See https://getcomposer.org/root for details
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.5.2 2017-09-11 16:59:25