How to install Drush for Drupal 7

drush

What is Drush?

Drush is a command line shell and Unix scripting interface for Drupal. Drush core ships with lots of useful commands for interacting with code like modules/themes/profiles. Similarly, it runs update.php, executes sql queries and DB migrations, and misc utilities like run cron or clear cache.

Simply put, you can perform administrative tasks far more efficiently with Drush than you can with the Drupal administration control panel in the web browser. An efficient Drupal 7 developer must use Drush.

Install Drush

Download and install the Drush command-line software. There are a few ways you can do this.

If you are running Linux, you can most likely install Drush with the operating system’s native package manager. Operating system’s package manager may install an older version.

CentOS/RHEL

# sudo yum install drush

OS X with Homebrew

# brew install drush

Ubuntu/Debian

# sudo apt-get install drush

Install Drush using Composer

If you have already  installed Composer on your system, you can use it to install Drush.

composer global require drush/drush:6.*

Also want to make sure the Composer binaries directory is added to your system path.

sed -i ‘1i export PATH=”$HOME/.composer/vendor/bin:$PATH”‘ $HOME/.bashrc

Install Manually Drush

Manually download and install Drush, but you must have Composer already installed first. When you’re ready to manually install Drush:

# Create a bin directory for your user account and add to system path
mkdir $HOME/bin
echo “PATH=$HOME/bin:$PATH” >> ~/.bashrc
source ~/.bashrc

# Download and unzip the Drush software
wget -O $HOME/bin/drush.zip https://github.com/drush-ops/drush/archive/master.zip
unzip -d $HOME/bin $HOME/bin/drush.zip

# Install Drush dependencies with Composer (assumes `composer` is on system PATH)
cd $HOME/bin/drush-master
composer install

# Create a symbolic link
ln -s $HOME/bin/drush-master/drush $HOME/bin/drush

Once you have downloaded and install the Drush software, you can open your Terminal/Console application, type drush, and hit ENTER.