阿里云Ubuntu16.04 PHP 安装composer

根据 composer 中国镜像](https://www.phpcomposer.com/)的教程:

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

例子:

root@AY131014140120Z:~# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

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

root@AY131014140120Z:~# mv composer.phar /usr/local/bin/composer
root@AY131014140120Z:~# composer -v
-bash: /usr/bin/composer: No such file or directory

我擦!环境变量需要设置一下:

•/etc/profile —— 此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.并从/etc/profile.d目录的配置文件中搜集shell的设置;

vim /etc/profile
按 I 键进行修改:
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games”
按 ESC 退出,输入 :wq 保存
(为刚入门的同鞋解释一下!)
结果:

root@AY131014140120Z:~# composer
Do not run Composer as root/super user! See https://getcomposer.org/root for details
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.6.5 2018-05-04 11:44:59

Do not run Composer as root/super user! 这是个警告,composer还是可以运行的

最后配置中国镜像:

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

你可能感兴趣的:(构建开发环境)