Installing Composer on Rocky Linux 9

Hello,

In this week’s feature highlight, we look at How to How to Install Composer on Rocky Linux 9

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

Output:

[root@server ~]# dnf install php
Last metadata expiration check: 2:53:03 ago on Tue 19 Jul 2022 08:34:16 PM CEST.
Package php-8.0.13-1.el9.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

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@server ~]#     wget https://getcomposer.org/installer -O composer-installer.php
--2022-07-19 23:29:07--  https://getcomposer.org/installer
Resolving getcomposer.org (getcomposer.org)... 54.36.53.46, 2001:41d0:302:1100::8:104f
Connecting to getcomposer.org (getcomposer.org)|54.36.53.46|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 58140 (57K) [application/octet-stream]
Saving to: ‘composer-installer.php’

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

2022-07-19 23:29:08 (6.32 MB/s) - ‘composer-installer.php’ saved [58140/58140]

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@server ~]# composer --version
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? y
Composer version 2.3.10 2022-07-13 15:48:23

Testing Composer

To test your installation, run the following command.

composer

Output:

[root@server ~]# composer
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? y
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.3.10 2022-07-13 15:48:23

Usage:
  command [options] [arguments]
(Visited 223 times, 1 visits today)