Skip to main content
Lütfiye Turan
Lütfiye Turan

How do I install a Drupal module?

With a total of over 42,000 provided modules (so-called contrib modules) and more than 6,900 compatible modules for version 8, Drupal allows us to build and customize a website according to our own ideas using existing modules and themes alone. The globally active Drupal community ensures that these extensions are constantly updated and kept secure. You can find out what contrib modules are or how to create your own modules in our blog article"2 easy ways to create a Drupal".

A list of all available modules can be found on drupal.org. Here you can search for specific modules, but also discover completely new ones: For example, there is an overview of the modules which have been downloaded or installed most frequently by the Drupal community.

Once you have landed on the module page of a desired module, you will find a short summary of the module, links to documentation, statistics and further information.

1. download via drupal.org

At the bottom of the page there is a download link (to the left of the sign and the release date) for various Drupal versions. To ensure the functionality of the module, it is recommended to always install the module version with the prefix of your Drupal version. So if you have a Drupal 8 site, please select the "8.x" version. The same applies to Drupal 7.

Please also pay attention to the shield symbol before downloading a module. These security notices are managed by the Drupal Security Team and mark modules that are compliant or non-compliant with the security standards.

To ensure that your project always remains secure, you should only install modules if you know that the installation will not entail any risks.

Integrate into Drupal

Once you have successfully downloaded the module, unzip it and you will receive a folder named after the module. The folder must now be integrated into Drupal. To do this, move this folder to your project directory. Modules provided by the Drupal community are stored in the path "modules/contrib" by default.

Installing the module

After the module has been integrated into Drupal, the module is installed. If you go to "Extend" in the admin area of your site, you will see a list of all the modules that are available to you. In addition to a short description of the module, you will also receive information about the version of the module, "requirements" (dependencies of modules), or you can go directly to the module configuration. By selecting the respective checkbox and then clicking on "Install", the modules are installed and activated.

2. downloading via Composer

Composer is a dependency manager (package manager) for PHP, which takes care of resolving dependencies and automatically downloading all required libraries in the configured version into your project. If Composer is not yet installed on your system, you can find instructions for Linux here. Contrib modules provided by the community can often have multiple dependencies. Without Composer, you would have to take care of all dependencies when downloading the modules. Downloading via Composer is the procedure recommended by Drupal.

The following command on the command line can be used to install modules with Composer.

composer require drupal/module_name

To download the "ctools" module, execute the following command, for example:

composer require drupal/ctools

A new "ctools" folder is automatically created in "modules/contrib" and the module is now available for activation in the list of all available modules. Please note that this command only downloads modules, but does not activate them!

To activate, go to "Extend" in the admin area of your site as described above, select the relevant checkbox and then click on "Install".

If you do not want to download the latest version of a module, but a specific version, you can specify the version as follows:

composer require drupal/module_name:version

Further information can be found here under "Specifying a version".

Activate with Drush

A module can also be activated using drush. Drush stands for Drupal Shell and is a terminal tool for managing Drupal websites. Drush makes it possible to carry out a variety of administrative tasks directly in the command line. This not only saves a lot of time, but also allows the developer to concentrate on their work without being distracted by switching back and forth between the terminal and the user interface. To activate a module with drush, execute the following command:

drush en module_name

To switch on the "ctools" module, for example, execute the following command:

drush en ctools

3. download and install via Drupal Console

Modules can also be installed via Drupal Console. Please note, however, that your composer.json file will not be adjusted automatically.

You can install modules with Drupal Console using the following command on the command line:

dupal moi module_name

For example, to install the "ctools" module, execute the following command:

drupal moi ctools

Unlike when downloading with Composer, the module is not only downloaded here, but also activated at the same time. However, existing dependencies must be checked manually.

Conclusion

We hope that this article has shown you various ways and tools that will help you to successfully download and install a module.

Even though it has already been mentioned here that Composer is the way recommended by Drupal to manage dependencies of modules and other extensions, the other ways of course remain open. Since all of these methods ultimately lead to the goal and a distinction must also be made here according to the use case, the decision is of course always yours.

Are you still working with an outdated Drupal version? We offer you an upgrade service, find out more: Drupal 9 Upgrade