Paridhi SolutionsBlog
Magento

How to Install Composer on Ubuntu 24.04 LTS (Complete Step-by-Step Guide)

Learn how to install Composer on Ubuntu 24.04 LTS. This guide covers downloading Composer, verifying the installation, updating Composer, troubleshooting common issues, and preparing your server for modern PHP applications.

Paridhi Solutions
2026-07-02
4 min read read
How to Install Composer on Ubuntu 24.04 LTS (Complete Step-by-Step Guide)

How to Install Composer on Ubuntu 24.04 LTS

Composer is the most popular dependency manager for PHP. Modern PHP applications such as Magento, Laravel, Symfony, and many other frameworks use Composer to install and manage packages.

In this guide, you'll learn how to install Composer on Ubuntu 24.04 LTS, verify the installation, update Composer, and troubleshoot common issues.


What is Composer?

Composer helps developers manage PHP dependencies efficiently.

Instead of manually downloading libraries, Composer automatically installs and updates the required packages for your project.

For Magento, Composer is used to:

  • Install Magento
  • Install extensions
  • Update Magento
  • Manage third-party libraries
  • Install patches

Prerequisites

Before installing Composer, ensure you have:

  • Ubuntu 24.04 LTS
  • PHP installed
  • Terminal access
  • Internet connection

Verify PHP is installed:

bash
php -v

If PHP isn't installed yet, follow our PHP installation guide first.


Step 1 — Update Ubuntu

Always update your package list before installing software.

bash
sudo apt update
sudo apt upgrade -y

Step 2 — Install Required Packages

Install the packages Composer requires.

bash
sudo apt install curl unzip php-cli php-mbstring git -y

These packages provide:

  • curl → Download files
  • unzip → Extract packages
  • php-cli → Run Composer
  • git → Download repositories

Step 3 — Download Composer Installer

Download the official Composer installer.

bash
curl -sS https://getcomposer.org/installer -o composer-setup.php

Step 4 — Verify the Installer (Recommended)

Composer publishes a SHA-384 installer signature.

Download the latest signature from the official Composer website and compare it with the downloaded installer before running it.

This helps ensure the installer has not been modified.


Step 5 — Install Composer

Run:

bash
sudo php composer-setup.php \
--install-dir=/usr/local/bin \
--filename=composer

You should see:

text
Composer successfully installed.

Step 6 — Verify Installation

Check the installed version.

bash
composer --version

Example:

text
Composer version 2.x.x

Step 7 — Check Composer Diagnostics

Run:

bash
composer diagnose

Composer will verify:

  • PHP version
  • SSL configuration
  • Disk space
  • Git availability
  • Required extensions

Resolve any reported issues before using Composer in production.


Step 8 — Update Composer

Update Composer to the latest version.

bash
composer self-update

Verify again:

bash
composer --version

Step 9 — Test Composer

Create a temporary directory.

bash
mkdir composer-test

cd composer-test

Initialize Composer.

bash
composer init

If the wizard starts successfully, Composer is installed correctly.


Common Composer Commands

Update dependencies.

bash
composer update

Install dependencies.

bash
composer install

Show installed packages.

bash
composer show

Clear Composer cache.

bash
composer clear-cache

Troubleshooting

Composer Command Not Found

text
composer: command not found

Verify the installation location.

bash
which composer

If necessary, reinstall Composer.


PHP Version Too Old

Check:

bash
php -v

Install a supported PHP version before using Composer.


Memory Limit Error

Increase PHP memory.

bash
php -d memory_limit=-1 composer install

Or permanently increase the memory limit in php.ini.


Permission Denied

Ensure Composer is installed in:

text
/usr/local/bin/composer

Verify permissions.

bash
ls -l /usr/local/bin/composer

Best Practices

  • Always use the latest stable Composer release.
  • Keep Composer updated regularly.
  • Verify the installer before installation.
  • Avoid running Composer as the root user inside application directories unless necessary.
  • Commit composer.json and composer.lock to version control.

Frequently Asked Questions

Is Composer free?

Yes.

Composer is open source and free to use.


Do I need Composer for Magento?

Yes.

Magento uses Composer for installation, updates, and dependency management.


How do I update Composer?

Run:

bash
composer self-update

Where is Composer installed?

Typically:

text
/usr/local/bin/composer

How do I check the Composer version?

bash
composer --version

Conclusion

Congratulations! 🎉

You've successfully installed Composer on Ubuntu 24.04 LTS.

Composer is now ready to manage PHP dependencies for Magento and other PHP applications.


Continue the Magento Installation Series

Next tutorial:

➡️ How to Install MySQL 8 on Ubuntu 24.04 LTS

Upcoming guides:

  • Install OpenSearch
  • Install Redis
  • Install Nginx
  • Install Magento 2.4.8
  • Configure Production Mode
  • Configure Cron Jobs

Tags

ComposerUbuntuUbuntu 24.04PHPMagento

Written by

Paridhi Solutions

Publishing in-depth tutorials, coding guides, and best practices for modern web development.

Visit Website →

Share this article

Related Articles