—- 参照(多謝!)
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ ls -l
total 288 -rw-rw-r-- 1 vagrant vagrant 293630 Aug 3 07:45 composer-setup.php
つぎに、ダウンロードした composer-setup.php を実行して、Composer の実行ファイル(phar)を作成します。 セットアップ終了後、ls コマンドで composer.phar ができたことを確認します。
$ php composer-setup.php
All settings correct for using Composer Downloading 1.2.0... Composer successfully installed to: /home/vagrant/composer.phar Use it: php composer.phar
$ ls -l
total 1956 -rwxr-xr-x 1 vagrant vagrant 1705467 Aug 3 07:45 composer.phar -rw-rw-r-- 1 vagrant vagrant 293630 Aug 3 07:45 composer-setup.php
composer.phar が作成できたので、セットアップスクリプト(composert-setup.php)は不要なので削除します。$ php -r "unlink('composer-setup.php');"
$ ls -l
total 1668
-rwxr-xr-x 1 vagrant vagrant 1705467 Aug 3 07:45 composer.phar
これで Composer のセットアップが完了です。
動作確認
composer が利用できるようになったのかを確かめるため、作成された composer.phar を実行してみましょう。 つぎの例のように、Composer のロゴとオプション一覧が出れば、動作確認完了です。
$ ./composer.phar -v
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.2.0 2016-07-19 01:28:52
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.
(以下略)
Globallyにインストール
CentOS のどこからでも(Globallyに)使えるようにするために、 /usr/local/bin フォルダに composer.phar を移動させると良いでしょう。 次のように /usr/local/bin フォルダに移動させます。 (/usr 配下にファイルを配置するには root ユーザーの権限が必要です)
# mv composer.phar /usr/local/bin/composerこれで、CentOS のどこからでも composer というコマンドで実行できるようになります。
$ composer
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.2.0 2016-07-19 01:28:52
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.
(以下略)

