Install Composer for Ubuntu 14.04 LTS and Drupal 7

Written by Mark Chambers on November 11, 2016


  1. Prepare server
  2. Install Composer globally
  3. Install drush via Composer
  4. Install and enable Composer Manager module in Drupal
  5. Get BAT libraries via Composer

Although these instructions are for getting Booking and Availability Tools running on Drupal, each section stands on its own and may be useful for other purposes.

These instructions are for Ubuntu 12.04.5 LTS, and also tested on 14.04.5 LTS with PHP 5.6. It may need to be slightly adjusted for other versions of Linux.

1. Prepare server

A couple things are required on your Ubuntu server.

Install packages

sudo apt-get install curl git zip unzip

Restart Apache

sudo service apache2 restart

2. Install Composer globally on server

Important: Do not install Composer as root

2.1: Download and install

curl -sS | sudo php -- --install-dir=/usr/local/bin --filename=composer

To test your installation, run:


You should get this output:

All settings correct for using Composer
Downloading 1.2.2...

Composer successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
dev@bornkamp:~$ composer
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
Composer version 1.2.2 2016-11-03 17:43:15

  command [options] [arguments]

  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:


2.2: Correct permissions

Run this to fix cache directory write permission errors:

sudo chown -R $USER $HOME/.composer

3. Install Drush

3.1: Install latest stable Drush:

composer global require drush/drush

3.2: Verify that Drush works:

drush status

4. Install and enable Composer Manager module in Drupal

4.1: Get the latest stable version of the module from here:

4.2: Install and enable the module

4.3: Set Composer Directories

In a web browser, go to:

Set the Vendor directory and Composer File Directory to appropriate locations.

4.4: Linking composer with Drupal

Open a terminal window and go to the Composer File Directory and run the following command:

composer install

5. Get BAT libraries via Composer

5.1: Run composer update

Open a terminal window and go to the Composer File Directory and run the following command:

composer update

If it throws a PHP version error then go to the next step.

If no errors appear, then you are finished!

5.2: Force composer to update

Run this command:

composer update --ignore-platform-reqs

BAT should now be installed and ready to configure.