How to Install PHP Composer on CentOS Stream 10

Composer is a dependency manager for the programming language, PHP. It functions as some sort of project manager that helps the programmer manage dependencies that will be used on a project-to-project basis.

Installing PHP

Install PHP by running the below command,

dnf install php

Download Composer installer

Install wget package to download files from the internet.

dnf -y install wget

Install Composer locally by running the following command,

wget https://getcomposer.org/installer -O composer-installer.php
[root@server ~]# wget https://getcomposer.org/installer -O composer-installer.php
--2025-02-20 13:21:34--  https://getcomposer.org/installer
Resolving getcomposer.org (getcomposer.org)... 142.44.245.229, 2607:5300:201:2100::4:d105
Connecting to getcomposer.org (getcomposer.org)|142.44.245.229|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 58444 (57K) [application/octet-stream]
Saving to: ‘composer-installer.php’

composer-installer.php                          100%[====================================================================================================>]  57.07K  --.-KB/s    in 0.08s

2025-02-20 13:21:34 (722 KB/s) - ‘composer-installer.php’ saved [58444/58444]

Installing PHP Composer

Run the downloaded composer installation file with the below command,

php composer-installer.php --filename=composer --install-dir=/usr/local/bin 

Verify the PHP Composer version once the installation is done,

composer --version
[root@server ~]# composer --version
Composer version 2.8.6 2025-01-21 15:23:40
PHP version 8.3.15 (/usr/bin/php)
Run the "diagnose" command to get more detailed diagnostics output.

Testing Composer

To test your installation, run the following command.

composer
[root@server ~]# composer
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.8.5 2025-01-21 15:23:40

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

Now you have successfully installed Composer on your CentOS Stream 10.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS