【CentOS stream 9】 composerをインストール

2022年6月13日

ConoHa VPSのCentOS stream 9にphpのパッケージ管理ツール「composer」をインストールします。

関連記事 Apache系インストール
1.ConoHa VPS のSSHセキュリティを強化する
2.【CentOS stream 9】 Apacheをインストールする
3.【CentOS stream 9】 Maria DBをインストールする
4.【CentOS stream 9】 phpをインストールする
5.【CentOS stream 9】 composerをインストールする
関連記事 Nginx系インストール
1.ConoHa VPS のSSHセキュリティを強化する
2.【CentOS stream 9】 Nginxをインストールする
3.【CentOS stream 9】 Maria DBをインストールする
4.【CentOS stream 9】 phpをインストールする
5.【CentOS stream 9】 Nginxでphp、phpMyAdminを使う
6.【CentOS stream 9】 composerをインストールする
7.【CentOS stream 9】 Nginxに let's encrypt SSL証明書インストール
関連記事 ドメイン
ConoHa WING VPS に サブドメインを追加する

composerインストール手順

dnf installコマンドで「composer」をインストールします。

# dnf install composer
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Last metadata expiration check: 0:43:02 ago on Wed 25 May 2022 02:16:37 AM JST.
Dependencies resolved.
===========================================================================================================
 Package                  Architecture           Version                        Repository            Size
===========================================================================================================
Installing:
 composer                 noarch                 2.3.5-1.el9                    epel                 819 k

Transaction Summary
===========================================================================================================
Install  1 Package

Total download size: 819 k
Installed size: 4.5 M
Is this ok [y/N]: y
Downloading Packages:
composer-2.3.5-1.el9.noarch.rpm                                            7.6 MB/s | 819 kB     00:00
-----------------------------------------------------------------------------------------------------------
Total                                                                      1.9 MB/s | 819 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                   1/1
  Installing       : composer-2.3.5-1.el9.noarch                                                       1/1
  Verifying        : composer-2.3.5-1.el9.noarch                                                       1/1
Installed products updated.

Installed:
  composer-2.3.5-1.el9.noarch

Complete!

「php8.1」をremiリポジトリからインストールしていて、

「php-zip」「php-intl」が必要です。というようなエラーが表示されてインストールできない時は、

 Problem: package composer-2.3.5-1.el9.noarch requires php-zip, but none of the providers can be installed

 Problem: package composer-2.3.5-1.el9.noarch requires php-intl, but none of the providers can be installed

php-zipをインストールしてから、composerをインストールします。

# dnf --enablerepo=remi install php-zip
# dnf --enablerepo=remi install php-intl

composerのバージョン確認

「composer」コマンドでバージョン確認ができます。

# composer
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.3.5 2022-04-13 16:43:00

Usage:
  command [options] [arguments]

Options:
  -h, --help                     Display help for the given command. When no command is given display help for the list command
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi|--no-ansi           Force (or disable --no-ansi) ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
      --no-scripts               Skips the execution of all scripts defined in composer.json file.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
      --no-cache                 Prevent use of the cache
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  about                Shows a short information about Composer.
  archive              Creates an archive of this composer package.
  browse               [home] Opens the package's repository URL or homepage in your browser.
  check-platform-reqs  Check that platform requirements are satisfied.
  clear-cache          [clearcache|cc] Clears composer's internal package cache.
  completion           Dump the shell completion script
  config               Sets config options.
  create-project       Creates new project from a package into given directory.
  depends              [why] Shows which packages cause the given package to be installed.
  diagnose             Diagnoses the system to identify common errors.
  dump-autoload        [dumpautoload] Dumps the autoloader.
  exec                 Executes a vendored binary/script.
  fund                 Discover how to help fund the maintenance of your dependencies.
  global               Allows running commands in the global composer dir ($COMPOSER_HOME).
  help                 Display help for a command
  init                 Creates a basic composer.json file in current directory.
  install              [i] Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.
  licenses             Shows information about licenses of dependencies.
  list                 List commands
  outdated             Shows a list of installed packages that have updates available, including their latest version.
  prohibits            [why-not] Shows which packages prevent the given package from being installed.
  reinstall            Uninstalls and reinstalls the given package names
  remove               Removes a package from the require or require-dev.
  require              Adds required packages to your composer.json and installs them.
  run-script           [run] Runs the scripts defined in composer.json.
  search               Searches for packages.
  show                 [info] Shows information about packages.
  status               Shows a list of locally modified packages.
  suggests             Shows package suggestions.
  update               [u|upgrade] Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file.
  validate             Validates a composer.json and composer.lock.
#
CentOS stream 9 composerをインストールする
CentOS stream 9 composerをインストールする

参考サイト

CentOS Stream 9 でさくっとLAMP環境を作る at softelメモ

【Amazon Linux】サーバーにComposerを入れる | Entersquare Inc.

CentOS+NginxでLaravelを動かすまで(サーバー構築)

仮想環境にCentOS Stream 9をインストールしてみた│ツインターボのブログ