To install Composer on AlmaLinux 8, install PHP and necessary dependencies using dnf install php-cli php-json php-zip wget unzip -y. Download the installer with {Link: wget https://getcomposer.org/installer -O composer-installer} and install it to /usr/local/bin using php composer-installer –filename=composer –install-dir=/usr/local/bin. Verify with composer –version.
Detailed Installation Steps
Install PHP and Dependencies: Ensure PHP, CLI, JSON, and Zip modules are installed.
bash
dnf install php-cli php-json php-zip wget unzip -y
Download Composer Installer: Download the installer script to the current directory.
bash
php -r “copy(‘https://getcomposer.org/installer’, ‘composer-setup.php’);”
Verify Installer (Optional but recommended): Verify the installer signature.
bash
HASH=”$(wget -q -O – https://composer.github.io/installer.sig)”
php -r “if (hash_file(‘SHA384’, ‘composer-setup.php’) === ‘$HASH’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;”
Install Composer Globally: Run the installer and move it to a system-wide path.
bash
php composer-setup.php –filename=composer –install-dir=/usr/local/bin
Verify Installation: Check the version to confirm successful installation.
bash
composer –version
Cleanup: Remove the installer file.
bash
rm composer-setup.php