On Amazon Linux 2023 Install PHP composer for your Project

On AWS service, Amazon Linux 2023 is the upgraded version for Amazon Linux 2 users, here we learn how to install PHP Composer on AL2023 using the command terminal.

Hosting popular web applications on AWS using Amazon Linux 2023 is a good choice because of long-term support and its RHEL-based code. Well, if you are planning to install or develop some PHP-based application you may require Composer which is a dependency manager for PHP just like NPM is for Nodejs and PIP for Python, It helps in downloading, updating, and autoloading various PHP libraries required by a project or application. Composer allows us to define the dependencies in a single file called composer.json.

Now, that we have a basic understanding of PHP Composer, let’s learn the commands we can use to install on your Amazon Linux 2023 instance.

Step 1: SSH AL2023 Instance:

Ofcourse, first we need access to our Amazon Linux 2023 terminal to execute the command. Therefore, either use web-based SSH from your AWS Dashboard or use the local terminal and connect AL2023 with the help of SSH protocol using a private key to authenticate.

Step 2: Execute DNF Update Command

After having access to the Amazon Linux terminal, the first thing we should do is run the system update command to install the latest software packages and security updates.

sudo dnf update 

Step 3: Install Dependencies:

We know Composer is a dependency manager for PHP, therefore, our system must have PHP installed already before setting up the Composer. Hence, run the command of this step to install PHP and its related packages such as JSON extension, which is essential for Composer’s operation, if you haven’t already.

sudo dnf install php php-cli php-json


Step 4: Installing Composer on Amazon Linux 2023:

After completing the installation of the required dependencies, the next thing we need to do is execute a script using cURL that will automatically install the Composer on our Amazon Linux 2023.

curl -sS https://getcomposer.org/installer | php
installing Composer AL2023


Step 5: Move PHP Composer Executable:

Although we have completed the PHP-Composer installation successfully, its executable will remain in our current directory, and we will not be able to call or use it globally from anywhere on our system. To solve this, we just need to move the “composer.phar” executable file to a directory in your system’s PATH to make it globally accessible. Use the following command:

sudo mv composer.phar /usr/local/bin/composer


Step 6: Check the Version

Now, let’s verify the Composer installation and whether it is accessible globally or not by running its version-checking command:

composer --version

If the result appears with the composer version details, the installation is successful, whereas to get the of options available to use with it, run the “help” command:

composer --help 
Installing and checking PHP composer on Amazon linux 2023



Like PHP, installing its dependency manager “Composer” on Amazon Linux 2023 is not a difficult task. Using it you will have an assistant for your PHP project to easily manage dependencies and streamline your web development projects.

Other Articles:


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.