ひじりんのひつまむしブログ

現役システムエンジニアのゲームやら映画やら技術やら・・

CentOSにPHPのcomposerをインストール

Composerとは

Composerとは、php上の部品を管理するツール

 

インストール

セットアップのプログラムをダウンロード

# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

# ls -l
total 72
-rw-r--r--. 1 root root 58460 May 26 08:03 composer-setup.php

ダウンロードしたものを実行

# php composer-setup.php

All settings correct for using Composer
Downloading...

Composer (version 2.0.14) successfully installed to: /root/composer.phar
Use it: php composer.phar

json がないとエラーがなった場合は

Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The json extension is missing.
Install it or recompile php without --disable-json

というエラーになり、下記でインストールする

# yum -y install php-json

 

動作

# ./composer.phar
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 2.0.14 2021-05-21 17:03:37

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

 

 

composer を /usr/local/bin にコピーまたは移動しておくとよい

# mv composer.phar /usr/local/bin/composer

 

PVアクセスランキング にほんブログ村