Install PHP composer on Rocky Linux 8
Composer is an application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries.Composer will pull in all the required PHP packages your project depends on and manages them for you. It is used in all modern PHP frameworks and platforms such as Laravel, Symfony, Drupal, and Magento2 etc.
This tutorial will describes about how to install php composer on Rocky Linux 8
Also Read -> How to Install Elasticsearch on Rocky Linux 8
Step 1: update packages
make sure your system is uptodate and also install php-cli and other dependency packages using dnf command.
sudo dnf update
sudo dnf install php-cli php-json php-zip wget unzip
Also Read -> How to Install NodeJS and NPM on Rocky Linux 8
Step 2: download and verify composer script
once packages are installed,download composer script with below command.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
To verify that the installation script is not corrupted, use below commands.
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;"
If the hashes match, the following message will display.otherwise it will show as installer corrupt.
output:
Installer verified
ALso Read -> How to Migrate from Centos 8 to Alma Linux 8
Step 3: install composer
now install the composer in /usr/local/bin directory.
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
output:
All settings correct for using Composer
Downloading...
Composer (version 2.1.9) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
Above command installs composer as a system-wide command and available for all users.
Now you can verify composer version
composer -V
output:
Composer version 2.1.9 2021-10-05 09:47:38
you can also install composer in quick way with the following commands.
sudo dnf install php-cli php-json php-zip curl unzip
curl -sS https://getcomposer.org/installer |php
sudo mv composer.phar /usr/local/bin/composer
That's it. Now you have successfully installed php composer on Rocky Linux 8.
Also Read -> How to Install PostgreSQL on Rocky Linux