How to install Drush using CGR and Composer
* Tested on Ubuntu 18.04
1. Install the composer Globally using the below commands
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') ===
'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24
ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; }
else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
2. Move the downloaded
mv composer.phar /usr/local/bin/composer
* If you like to install it only for your user and avoid requiring root permissions,
you can use ~/.local/bin
instead which is available by default on some
Linux distributions.
3. Install CGR
Add the path in /etc/environment like
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$HOME/.config/composer:$HOME/.config/composer/vendor/bin"
Export the path in ~/.bashrc like
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
export PATH="$(composer config -g home)/vendor/bin:$PATH"
cd ~
composer global require consolidation/cgr
4. Install Drush using CGR
cgr drush/drush [For the latest version]
cgr drush/drush:7.* [For drush 7]
5. Create symbolic link inside the /usr/bin to work on drush Globally