Find by Category

Installing Drush with Composer Globally on Ubuntu 20.04

This post will help you install Drush globally on Ubuntu Desktop 20.04 and Ubuntu Server with Composer. Go ahead and launch your terminal and run the following commands.

Update Ubuntu

sudo apt update

Install PHP cli and unzip exts

sudo apt install php-cli unzip

Install Composer on Ubuntu

cd ~
curl -sS -o composer-setup.php

Add Latest HASH to Composer installation

HASH=`curl -sS`

Verify Composer HASH

echo $HASH

You should see the latest Composer HASH

Verify Composer Installation

php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

You Should see

Installer verified

Set Composer Installation directory

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

Check Composer Version

composer --version

Install PHP extensions for Drush

sudo apt-get update 
sudo apt install php-xml php-mbstring

Install Drush Launcher

wget -O drush.phar
chmod +x drush.phar
sudo mv drush.phar /usr/local/bin/drush

Install Drush with Composer

sudo composer global require drush/drush 
sudo composer global require drush/drush:dev-master

Set Drush path

To add drush to your PATH, check where is your drush on your system with following command and

composer config --global home

On my system it returns /home/aks/.config/composer replace this return in the drush PATH line below to your .bashrc

Add this to your .bashrc – replace USER with your username

export PATH="/home/USER/.config/composer/vendor/drush/drush:$PATH"


export PATH="home/USER/.composer/vendor/drush/drush:$PATH"
source .bashrc
drush --version

You Should See Latest Version of Drush

Drush Commandline Tool 10.3.1

Drupal Module Development Online Course

This is best Drupal module development course, if you want to master the Drupal backend development