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 email@example.com -p 22
ii. Then, we change the directory to the user’s home directory.
iii. Next, we download the latest version of Drush using the following command.
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.
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.
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.
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.
ii. Then, we locate the line memory limit and raise the value to 500Ms.
iii. Finally, we save the file to reflect the changes made.
That's how we fixed the problem with Drush in Drupal 8.