How to Install Composer on Ubuntu (24.04) for Easy Drupal Module & Theme Updates

| Drupal Development | 379 seen

As a Drupal developer, keeping your modules up to date is crucial for security and performance. To streamline this process, I use Composer—a powerful dependency manager for PHP. It allows me to quickly update Drupal modules without the hassle of manually downloading and configuring each one. In this guide, I will walk you through the process of installing Composer on Ubuntu 24.04.

I typically run Drupal on an Ubuntu-based server with Nginx as the web server. This combination provides excellent performance and stability for hosting Drupal sites. Composer plays a crucial role in managing dependencies efficiently in this environment.

Composer is a dependency management tool for PHP that simplifies the installation and updates of libraries and packages. Instead of manually downloading and integrating each module, Composer automates the process, ensuring you always have the latest stable versions of your dependencies.

Step-by-Step Guide to Installing Composer on Ubuntu 24.04

1. Update Your System

Before installing any new software, ensure your system is up to date by running:

sudo apt update && sudo apt upgrade -y

2. Install Required Dependencies

Composer requires PHP and other dependencies. Install them using:

sudo apt install php-cli unzip curl -y

3. Download and Install Composer

Run the following commands to install Composer globally:

curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer

Alternatively, you can use the official installation method:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');"

Move Composer to a global location:

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

4. Verify Installation

After installation, verify that Composer is working by running:

composer -V

You should see the version number displayed, confirming a successful installation.

Using Composer for Drupal Module Updates

Once Composer is installed, updating Drupal modules becomes a breeze. Here’s how you can do it:

  1. Navigate to your Drupal project’s root directory:

    cd /path/to/your/drupal/site

  2. To update a specific module, run:

    composer update drupal/module_name --with-dependencies

  3. To update all modules and dependencies, use:

    composer update

  4. Clear the Drupal cache to apply updates:

    drush cache:rebuild

Using Composer simplifies Drupal module updates, ensuring you always have the latest security patches and features. With just a few commands, you can maintain your Drupal site efficiently and avoid potential compatibility issues. My usual setup involves Ubuntu with Nginx, and Composer integrates seamlessly into this environment, making dependency management straightforward.

Let me know in the comments if you have any questions or need further assistance.

 

Latest articles

Ādģēri: The 30K Mistake That Turned Into a Long-Term Experiment

In 2023, we bought Ādģēri in an online auction.Price: just over €30,000.Financing: ~6% interest.Total expected payment over ~5 years: ~€40,000.Status (April 2026): more than half already paid.On paper, it was a bad deal.Realistically, we overpaid by at least 5–6× relative to what the property was objectively worth at the time. No serious buyer…

Ādģēri |

Berlin Zoo and Aquarium: One of the Best Things To Do in Berlin With Kids

At the start of April 2026, during our roughly five-day trip to Berlin, we finally visited the famous Berlin Zoo for the first time - or at least the first time I can actually remember. There is a chance my mom might have taken me here sometime in the early 1990s, but if so, those memories are long gone. This visit felt completely new, and…

Germany |