在 Ubuntu 上安装 Composer

在下载和安装 Composer 之前,我们需要确保我们的服务器已安装所有依赖项。

首先,运行以下命令更新包管理器缓存:

sudo apt-get update

现在,让我们安装依赖项。我们需要 curl 才能下载 Composer 和 php5-cli 来安装和运行它。Composer 使用 git 来下载项目依赖项。可以使用以下命令安装所有内容:

sudo apt-get install curl php5-cli git

现在让我们安装它:

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

这将在/ usr / local / bin 下下载并安装 Composer,作为名为 composer 的系统范围命令。输出应如下所示:

Output
#!/usr/bin/env php
All settings correct for using Composer
Downloading...

Composer successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

要测试你的安装,请运行:

composer

你应该得到类似这样的输出:

Output
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.0-dev (9859859f1082d94e546aa75746867df127aa0d9e) 2015-08-17 14:57:00

Usage:
 command [options] [arguments]

Options:
 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version
 --ansi                Force ANSI output
 --no-ansi             Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question
 --profile             Display timing and memory usage information
 --working-dir (-d)    If specified, use the given directory as working directory.

....