In this article, we will have explained the necessary steps to install PHP Composer on Rocky Linux 8. Before continuing with this tutorial, make sure you are logged in as a user with
sudo privileges. All the commands in this tutorial should be run as a non-root user.
A composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on. It is a command-line tool that installs all libraries and dependencies for your project from the packagist.org repository.
- Operating System with Rocky Linux 8
- Server IPv4 Address with Superuser Privileges (Root Access)
- Gnome Terminal for Linux Desktop
- PuTTy SSH client for Windows or macOS
- Powershell for Windows 10/11
- Familiar with DNF Commands
Install PHP Composer on Rocky Linux 8
Step 1. First, before you start installing any package on your Rocky Linux server, we always recommend making sure that all system packages are updated.
sudo dnf install epel-release sudo dnf update sudo dnf upgrade
Step 2. Install Required Packages.
Before installing Composer, you will need to install PHP dependencies required to install Composer:
sudo dnf install php-cli php-json php-zip wget unzip
Step 3. Install Composer on Rocky Linux 8.
To install PHP composer on Rocky Linux, Run the command below to download the PHP composer installer script:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
Then, install the Composer to the
/usr/loca/bin directory using the following command below:
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Verify the PHP Composer version once the installation is done:
Composer version 2.2.4 2022-01-19 00:30:36
Step 4. Testing Composer.
To test your installation, run the following command:
[[email protected] ~]# composer ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 2.2.4 2022-01-19 00:46:37 Usage: command [options] [arguments] Options: -h, --help Display this help message
That’s all you need to do to install Composer on Rocky Linux 8. I hope you find this quick tip helpful. For further reading on PHP Composer, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.