在 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.

....