How to Install Composer on Rocky Linux 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 using the dnf package manager as shown below,

dnf install php

Download Composer Installer

Install wget package to download files from the internet.

dnf -y install wget

Download the installer file from their official site using the wget command as shown below,

wget https://getcomposer.org/installer -O composer-installer.php

Output:

[root@vps ~]# wget https://getcomposer.org/installer -O composer-installer.php
--2025-06-16 07:17:16--  https://getcomposer.org/installer
Resolving getcomposer.org (getcomposer.org)... 57.128.19.244, 2001:41d0:304:300::18ef
Connecting to getcomposer.org (getcomposer.org)|57.128.19.244|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 58444 (57K) [application/octet-stream]
Saving to: ‘composer-installer.php’

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

2025-06-16 07:17:17 (6.84 MB/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 

Output:

[root@server ~]# php composer-installer.php --filename=composer --install-dir=/usr/local/bin
All settings are correct for using Composer
Downloading...

Composer (version 2.3.10) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

Verify the PHP Composer version once the installation is done

composer --version

Output:

[root@vps ~]# composer --version
Composer version 2.8.9 2025-05-13 14:01:37
PHP version 8.3.19 (/usr/bin/php)
Run the "diagnose" command to get more detailed diagnostics output.

Testing Composer

To test your installation, run the following command.

composer

Output:

[root@vps ~]# composer
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.8.9 2025-05-13 14:01:37

Usage:
  command [options] [arguments]

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