×


Install Drush on Drupal 8

Are you trying to install Drush on Drupal 8?

This guide is for you.


A free & open-source CMS to create & manage many websites, the effective use of Drupal 8 requires an interactive shell interface like Drush is important.

It's a very powerful tool that performs various tasks using commands in the terminal. However, installing Drush in Drupal 8 is quite tricky & requires good knowledge.


For Drupal users who are interested in adding some speed and flexibility to their workflow, this article introduces Drush, or the “Drupal shell.” Drush allows you to run scripts from the command line to manage your Drupal installation. 

For users who enjoy working from the shell, installing Drush is a quick, easy process that may save you a lot of time in the long run.


Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Drupal related queries.

In this context, we shall look into how to set up "Drupal 8 install Drush" & fix the related issues.


More about Drush?

The name Drush stands for DRUpal SHell. It's a command-line utility to communicate with Drupal CMS.

Drupal 8 uses Drush to manage  and also:

i. Detect errors and fix them.

ii. Bypass using the interface when the Drupal backend is unavailable.

iii. Do regular maintenance and updates.


For users who need speed & flexible workflow, Drush allows them to run scripts from the command line & manages Drupal.


How to Install Drush on Drupal 8 ?

Since it is a command-line interface, and easy to process, the Drush scripting interface primarily works on the command line.

Moving ahead, let's see how our Support Experts install Drush in Drupal 8.


i. First, we login into the server using SSH.

ssh username@example.com -p 22

ii. Then, we change the directory to the user’s home directory.

cd

iii. Next, we download the latest version of Drush using the following command.

wget https://ftp.drupal.org/files/projects/drush-8.x-6.0-rc4.tar.gz

iv. Next, we extract the archive file like this.

tar zxvf drush-8.x-6.0-rc4.tar.gz

v. Finally, we run the command to clear the Drupal caches.

drush cc all

The installation process is complete. Now, the user can use the Drush command easily.


Troubleshooting common Drush on Drupal 8 installation errors

From our experience in managing servers, we often see errors reported by customers while installing Drush in Drupal 8.

Let's take a closer look at the causes & how our Support Engineers fix them.


1. Incompatible Drush version

Recently, one of our customers after installing Drush in Drupal 8 tried to update Drupal modules with the command drush ups. However, it resulted in an error like this:

Command pm-updatestatus needs a higher bootstrap level to run - you  [error]
will need to invoke drush from a more functional Drupal environment
to run this command.

In order to solve this error, our Support Engineers performed the following steps:

i. Initially, we check the status by running the following command.

drush status

ii. By analyzing we found that the Drush version was 8.0.3. Generally, Drupal 8 supports higher versions of Drush 8.1.

iii. Then we remove & install the latest version of Drush.

wget https://github.com/drush-ops/drush/releases/download/8.1.3/drush.phar

iv. Next, we run the PHP file to verify the status

/usr/local/php5.5/bin/php drush.phar status

v. Finally, we ensure the correct version of Drush is installed by running this command.

drush version

That fixed the error & the user could run the Drush command without any failure.


2. PHP issue

Similarly, even after installing Drush properly, we may face issues with the site due to a lower value in the PHP parameter.

We may also receive an error on the website indicating that the memory limit has been reached & it results like this:

PHP Fatal error: Allowed memory size of ### bytes exhausted

PHP allows a default amount of memory to process a website. Sometimes, a website needs more than the default amount of memory.

To get around this error, our Support Engineers increased the memory limits.

i. Initially, we open the site’s configuration file.

vi /sites/default/settings.php

ii. Then, we locate the line memory limit and raise the value to 500Ms.

ini_set('memory_limit','500M');

iii. Finally, we save the file to reflect the changes made.


That's how we fixed the problem with Drush in Drupal 8.


[Having trouble with Drush in Drupal 8?  We'll fix it for you. ]


Conclusion

This article will guide you on steps to #install #Drush in #Drupal 8. Drush is a command-line utility to manage Drupal #CMS. For this installation of the Drush scripting interface, we will be working primarily on the command line. This is because Drush is a command line interface, and all of the commands you will use will need to be issued from there.

Drush is the command line shell and Unix scripting interface for Drupal.

To Install a global Drush via #Composer:

1. Install Composer globally.

2. Install the cgr tool following the instructions in that project.

3. Add composer's bin directory to the system path by placing export PATH="$HOME/.

4. Install latest stable Drush: cgr drush/drush .

5. Verify that Drush works: drush status.