Set up PHP Composer on AlmaLinux 8

In this article, we want to teach you How To Set up PHP Composer on AlmaLinux 8. Composer is a dependency manager for PHP. The composer will manage the dependencies you require on a project-by-project basis. This means that Composer will pull in all the required libraries, dependencies, and manage them all in one place.

You can now proceed to the guide steps below on the Orcacore website to set up PHP Composer on AlmaLinux 8.

How To Set up PHP Composer on AlmaLinux 8

Before you start to install PHP Composer on AlmaLinux 8, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article The Initial Server Setup with AlmaLinux 8.

Now, follow the steps below to set up PHP Composer on your server.

Step 1. Install Latest PHP Version on AlmaLinux 8

First, you need to update your local package index with the following command:

sudo dnf update -y

It is recommended to install the latest stable version of PHP on your server. To do this, you must install the EPEL repo and Remi repo on your AlmaLinux 8:

# sudo dnf install epel-release -y
# sudo dnf install -y dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Again, run the system update to apply the changes:

sudo dnf update -y

If you have PHP installed on AlmaLinux 8, remove the Previous PHP version installed with the commands below:

# sudo dnf remove php php-fpm -y
# sudo dnf remove php* -y

Then, list the PHP Remi module available on ALmaLinux 8:

sudo dnf module list reset php -y

In your output, you must see:

PHP Remi module available on ALmaLinux 8

As you can see, PHP REMI 8.4 is the latest version. To enable the module, run the command below:

sudo dnf module enable php:remi-8.4 -y

Next, install PHP with the following command:

sudo dnf install php -y

You can verify your PHP installation by checking its version:

php -v

In your output, you will see:

PHP version for Composer

Step 2. Install Composer on AlmaLinux 8

At this point, you need to download the Composer installer script. To do this, first, install the wget tool with the command below:

sudo dnf install wget -y

Then, use the wget command to download Composer:

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

When your download is completed, use the following command to install Composer on AlmaLinux 8:

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

In your output, you will see:

install Composer on AlmaLinux 8

You can verify your PHP Composer installation by checking its version:

composer --version

In your output, you will see:

Output
Composer version 2.8.10 
PHP version 8.4.11 (/usr/bin/php)

Access PHP Composer

Also, you can test your Composer on AlmaLinux 8 by using the command below:

composer

You will get the following output:

Access PHP Composer

With Composer, you can easily build, manage, and share PHP projects by taking care of the libraries and tools your project depends on.

Conclusion

As a PHP developer, Composer will become your best friend, and as its usage increases, it will become an essential part of writing PHP on a day-to-day basis.

At this point, you have learned to install PHP Composer on AlmaLinux 8. Hope you enjoy it. Please subscribe to us on Facebook, YouTube, and X.

May this article about installing and using Composer on Ubuntu 20.04 be useful for you.

You may also like to read the following articles:

Upgrading AlmaLinux 9 to 10 From CLI

Set up AlmaLinux 10 in a VMware

Initial Server Setup with AlmaLinux 10

Share your love

Stay informed and not overwhelmed, subscribe now!