Install Drupal Themes and Modules Using Drush on Debian 10
Updated by Linode Written by Linode
Drush is a command line tool, which can be used for various Drupal projects. This tutorial uses Drush to install themes, modules, and covering some basic administration tasks such as backup and migrate for Drupal websites.
Linode has another guide for installing Drush and creating a Drupal website, Install Drupal using Drush on Debian 10. Depending on your experience level with Drush, you may want to start with that guide.
Before You Begin
Before installing themes, modules, and a backup system with Drush, make sure that the following prerequisites have been met:
Familiarize yourself with our Getting Started guide and complete the steps for setting your Linode’s hostname and timezone.
Follow our Securing Your Server guide to create a standard user account, harden SSH access, remove unnecessary network services and create firewall rules for your web server; you may need to make additional firewall exceptions for your specific application.
Note
This guide is written for a non-root user. Commands that require elevated privileges are prefixed with
sudo
. If you’re not familiar with thesudo
command, visit our Users and Groups guide.All configuration files should be edited with elevated privileges. Remember to include
sudo
before running your text editor.Install and configure a LAMP stack on Debian 10
Install Composer and Drush on Debian 10
Make sure that your system is up to date, using:
sudo apt-get update && sudo apt-get upgrade
NoteThe Drush commands to download or enable themes and modules vary depending on the version of Drush that you have installed. This guide uses Drush 10.
Installing Themes with Drush
In this section you will download, enable, and set a Drupal theme using Drush.
Navigate to Drupal’s Download and Extend page to find the theme you want to download. The Drush download name is usually appended to the end of the Drupal theme page’s URL; for example,
drupal.org/project/project/my_theme
.Move into your Drupal site’s document root,
/var/www/html/example.com/public_html/
. Replaceexample.com
with your own domain’s name.cd /var/www/html/example.com/public_html
Download your desired theme using Composer. For example to download the
bootstrap
theme use:composer require drupal/bootstrap
Note
If you receive an error related to not being able to write to the
composer.json
file, see the Setting the Site’s Ownership and Permissions section of the Install Drupal using Drush on Debian 10 guide.Ensure that your
/var/www/html/example.com/public_html
directory has user and group read, write, and execute permissions.sudo chmod 774 -R /var/www/html/example.com/public_html
Enable the theme that you downloaded in the previous step. For example, to enable the
bootstrap
theme run the following command. Replacebootstrap
with the name of your theme.drush theme:enable bootstrap
As an example, set the Omega theme as the default and active theme:
drush config-set system.theme default omega
Check the homepage of your site and the new theme should appear.
Installing Modules with Drush
Downloading and enabling a module is similar to working with a theme. However, modules can be used for almost any purpose. From enhancing public-facing functionality to providing a better administrative UI; there are thousands of Drupal modules. It is helpful to use modules with clear documentation, since once a module is installed, its interface can be challenging to use if it is not well documented and designed by the contributor.
Move into your Drupal site’s document root,
/var/www/html/example.com/public_html/
. Replaceexample.com
with your own domain’s name.cd /var/www/html/example.com/public_html
Download the Backup and Migrate module. This module enables you to perform the backup, restore, and migrate tasks
composer require drupal/backup_migrate
Enable the
backup_migrate
module:drush en backup_migrate -y
Sign in to your Drupal site’s browser interface and navigate to the Extend menu item (or Administration > Extend). Under the OTHER section, the Backup and Migrate module will be listed and selected.
You have successfully installed and enabled a new module. The module is now running and ready to be used.
Backup a Drupal Site
It’s always important to keep regular backups of a website. Backups protect you from losing data due to configuration changes, vulnerabilities, or system failures. Backups should be stored on a separate system whenever possible. The Backup and Migrate module helps you to create backups of your site.
To configure backup and migrate, navigate to Administration > Configuration > Development > Backup and Migrate
For a quick backup, select the type of Backup Source and select the Backup Destination, and click Backup now
NoteAlways download a backup prior to updating or installing modules.
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
Join our Community
Find answers, ask questions, and help others.
This guide is published under a CC BY-ND 4.0 license.