1.下载安装脚本 - composer-setup.php - 到当前目录
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
2.执行安装过程
php composer-setup.php
3.删除安装脚本
php -r "unlink('composer-setup.php');"
4.全局安装
sudo mv composer.phar /usr/local/bin/composer(ubuuntu:/usr/bin/composer)
注意:安装之前一定保证php正确安装(检测:php -v查看版本号),保持composer版本更新命令:composer selfupdate
补充
Linux下全局安装composer方法
/下载composer
curl -sS https://getcomposer.org/installer | php
//将composer.phar文件移动到bin目录以便全局使用composer命令
mv composer.phar /usr/local/bin/composer
//切换国内源
composer config -g repo.packagist composer https://packagist.phpcomposer.com