欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Centos7.3安装Composer

程序员文章站 2022-07-07 18:36:35
...

1、下载composer.phar

# cd /mydata/

# curl -sS https://getcomposer.org/installer | php
// 如果是网络原因失败,多试几次,直到出现如下:
All settings correct for using Composer
Downloading...

Composer (version 1.8.5) successfully installed to: /mydata/composer.phar
Use it: php composer.phar

下载成功

2、把composer.phar移动到环境下让其变成可执行

//把此文件移动到 /usr/local/bin/目录下,并改名为composer,此目录为系统全局加载
[[email protected] mydata]# mv composer.phar /usr/local/bin/composer

3、测试:

//在任意位置
# cd /
# composer -v
Do not run Composer as root/super user! See https://getcomposer.org/root for details(不要在root超级用户下执行)
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.8.5 2019-04-09 17:46:47
......

4、修改镜像地址

#composer config -g repo.packagist composer https://packagist.phpcomposer.com
Do not run Composer as root/super user! See https://getcomposer.org/root for details (不要在root超级用户下执行)

上面 3、4都会提示“不要在root超级用户下执行”所以就更换一个用户吧(不更换也没问题),如下,就不会报这个提示了

#useradd niuxitong
#passwd niuxitong
  设置密码 niu2****7

#su  niuxitong
# composer -v    不再有此提示了
# composer config -g repo.packagist composer https://packagist.phpcomposer.com

到此 composer 已经安装完成