第2步:安装complser

现在可以运行以下命令来安装Composer

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

上面的命令将从维护者页面下载Composer并将其安装到/usr/local/bin目录中。

All settings correct for using Composer
Downloading. 
Composer (version 1.6.4) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

测试是否安装了Composer。

composer

输出:

jack@ubuntu1804:~$composer
   ______
 /____/___  ____ ___  ____  ____  ________  _____
///__ \/__ `__ \/__ \/__ \/___/_ \/___/
//___//_////////_///_/(__  )  __//
____/____/_//_//_/.___/____/____/___/_/
                    /_/
Composer version 1.6.4 2015-04-13 12:04:24
Usage:
  command [options] [arguments]
Options:
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

还可以通过运行下面的命令来升级composer。
升级与composer关联的所有包:

sudo composer self-update

第1步:安装PHP

composer需要PHP 5.3或者更高版本。
在Ubuntu上运行以下命令安装PHP

sudo apt install php

如果我们需要安装 Ubuntu默认存储库中不可用的其他版本的PHP,请运行以下命令以安装第三方存储库,其中包含PHP 7.0,7.1,7.2以及更高版本。

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt update

比如,运行以下命令以安装PHP 7.2.

sudo apt install php7.2
如何在ububuntu 16.04上安装PHP Composer | 17.10 | 18.04

PHP Composer是用于PHP的包依赖性管理工具,开发人员使用它来管理基于PHP的项目/应用程序。您可能已经看到一些PHP应用程序要求在系统上安装composer,以便安装并运行包。
PHP composer经常用于简化需要更轻松管理的动态PHP应用程序的安装和更新。使用composer Dependencies工具,可以轻松安装和管理这些软件包。它在名为composer.JSON的JSON文件中维护所需包的列表。

日期:2020-07-07 20:57:23 来源:oir作者:oir