Skip to content

Install CiviCRM on Drupal 8/9

About this document

This guide covers standard installation of CiviCRM on an existing Drupal 8 or 9 site. It assumes that you previously completed these tasks:

  1. Install Drupal 8 or 9, and...
  2. Review the CiviCRM requirements
Alternative: Civibuild for developers

If you plan to develop patches for CiviCRM on Drupal 8 or 9, then please read the Developer Guide for information about Buildkit and civibuild.

Get the code

Drupal 8 (D8) and Drupal 9 (D9) sites are typically administered with Composer. Composer is a dependency management tool which can add, upgrade, and remove software packages for your site.

CiviCRM is published as a suite of related packages. Our goal is to use Composer to add CiviCRM's packages to the D8 site.

If you do not work regularly with Drupal 8 or 9 and Composer, then you should take a refresher before installing CiviCRM.

Quick and dirty introduction to Drupal 8 or 9 with composer

Composer requires shell access to the D8/D9 site. It defines a command composer.

Many D8/D9 sites are initialized via composer, which means that composer is already available. This can be confirmed in the shell by running composer --version:

$ composer --version
Composer version 1.10.13 2020-09-09 11:46:34

It is possible that your system does not have composer -- for example, if you used a tar-based installation of D8, then you may never have needed composer before.

If composer is missing, then you must download and install it first. Additionally, you probably need to set composer's memory limit high enough for D8/D9.

Once you have composer, you need to navigate to the composer-root. You can recognize it by the following:

  • It has the files composer.json and composer.lock.
  • It has a subfolder vendor/.
  • It usually has a subfolder web/ (the web-root); alternatively, it may be the web-root.

A typical file-hierarchy might look like:

/var/www/                Composer-root
/var/www/   Composer-configuration
/var/www/   Composer-configuration
/var/www/            Web-root (usually)
/var/www/         Downloaded packages

To work with composer and D8/D9, you must open a shell and navigate to the composer-root, e.g.

cd /var/www/

Note: Drupal 9 and CiviCRM combinations require use of Composer 2.x.x

If composer is properly installed, then these example commands will add CiviCRM to D8 or D9:

cd /var/www/
composer config extra.enable-patching true
composer config minimum-stability dev
composer require civicrm/civicrm-{core,packages,drupal-8}:'~5.42'

You should adjust the example path (/var/www/ and the example version (~5.42) as needed.

If you'd like more details to understand these commands or common errors, then please drill-down below.

More detail: Enable patching

A handful of packages used by CiviCRM require extra patch-files.

This is possible with the popular cweagans/composer-patches plugin. However, you must opt-in to enable it.

More detail: Package stability

For any package in composer, there may be several available versions. Some have an official, well-defined name or number (e.g. v1.2.3), and these are called "stable" versions. Other versions have an interim name or number (e.g. v1.2.alpha1 or dev-master) indicating that additional testing is appropriate.

As a general rule, a new composer deployment will (and should) only use "stable" versions. CiviCRM, too, is generally built around "stable" dependencies. However, in some exceptional cases, CiviCRM requires an interim release of some libraries.

composer.json has two options which affect this: minimum-stability sets an absolute baseline, and prefer-stable expresses a general preference. Setting minimum-stability to dev enables to installation to proceed when there are exceptional cases. Setting prefer-stable to true means that composer will use stable releases whenever it can.

More detail: Compilation tasks

When you first install or upgrade to CiviCRM 5.31+, composer will prompt for permission to run CiviCRM compilation tasks. We recommend that you select [a]lways.

If you wish to suppress the prompt, see Composer Compile Plugin: Managing the root package (for site-builders).

More detail: Required packages
Package Description
civicrm/civicrm-core The primary CiviCRM codebase
civicrm/civicrm-drupal-8 The integration module for CiviCRM and D8/D9
civicrm/civicrm-packages A collection of third-party/legacy packages used by CiviCRM
civicrm/civicrm-asset-plugin A tool which automatically copies JS+CSS assets from CiviCRM to D8's web/ folder - required by civicrm/civicrm-drupal-8
More detail: Version constraints

The primary CiviCRM packages (civicrm-core, civicrm-drupal-8, civicrm-packages) have synchronized versions. If one package is installed with v5.35, then the others should also be v5.35.

The following expression references the three packages and applies the same version-constraint to each:


The expression ~5.42 is a version-constraint. It means that composer will install approximately v5.42. It may install a newer patch-release (e.g. 5.42.1) or a newer minor-release (e.g. 5.43.0). However, it will avoid major-releases (e.g. 6.0.0).

Many composer tutorials rely on composer to automatically choose package-versions. This is not recommended for CiviCRM and Drupal 8/9. Instead, package versioning should be explicit to ensure that:

  1. CiviCRM versions remain synchronized.
  2. CiviCRM stable releases are preferred over developmental releases.

Get the translations

I18n & L10n on Drupal 8 or 9

If installing with the GUI it is currently only possible to install CiviCRM in English (US) on Drupal 8/9. Adding the language files involves breaking with Composer best practices by writing the contents of the civicrm-l10n tarball into vendor/civicrm/civicrm-core or configuring the civicrm.l10n directory path after you install and placing the contents of the civicrm-l10n tarball into the configured directory.

Here Be Dragons...

The following steps are provided as an example - they are not supported or widely tested and may leave your site in a broken state. You use them at your own risk. No. Seriously...

You will also have to repeat these steps every time you upgrade CiviCRM.

The warnings above notwithstanding to install CiviCRM on Drupal 8/9 requires the following additional steps to prepare:

  1. Add cv to your Drupal 8/9 Site with: composer require civicrm/cv (composer installs of cv are currently broken for now use the manual install steps.)
  2. Grab the localisation (l10n) files and unpack the l10n and sql subfolders into vendor/civicrm/civicrm-core/

    • You'll find the l10n files on the CiviCRM Download page or from where VERSION is a recent version of CiviCRM.


    tar -zxvf civicrm-5.35.0-l10n.tar.gz
    cd civicrm/
    cp -R l10n/ ../vendor/civicrm/civicrm-core/
    cp -R sql/ ../vendor/civicrm/civicrm-core/
    cd ..
    rm -rf civicrm/

  3. If you've done this correctly, you should end up with vendor/civicrm/civicrm-core/l10n and vendor/civicrm/civicrm-core/sql/

    • You can remove any languages you don't need by deleting them before copying the l10n and sql folders.

Now we move onto Installing CiviCRM - Command line install

Run the installer

The installer verifies requirements, prepares the database, and initializes the configuration file. You may run the installer through the web interface (which is simpler) or the command-line interface (which has more options).

Run installer via Drupal 8/9 web UI
Installation options are very limited

Currently there is no interactive installer for CiviCRM on Drupal 8/9, so the installer uses a firm set of defaults, e.g.

  • English Language Data: It only installs data for US English. It cannot install data for other languages.
  • Shared Database: It only uses the shared CMS database. It cannot use a separate MySQL database for CiviCRM.
  • No Sample Data: It only installs an empty, baseline dataset. It cannot install sample data.

If you need to configure any of these options, then use the command-line installer.

Write permissions

It is critical that your web-server user is able to write to the web/sites/default/ directory in order to create civicrm.settings.php and that you have an appropriate value for execution time(s) and memory limit(s) as any interruption to the installer can (and will) result in an unusable install and require remedial steps to correct or a full reinstall! By default on Drupal 8.8+ this directory path is not writable by default, before installing you should ensure you grant write access to your web server user. With, e.g: sudo chmod u+w web/sites/default.

For multisite installations you'll also need to ensure your web server user has write access to additional sites e.g: sudo chmod u+w web/sites/

  1. Login to your Drupal site with administrator permissions.
  2. Navigate to Manage >> Extend or point your web browser to the following URL:

  3. Find "CiviCRM Core" and enable it (you can optionally enable "CiviCRM Theme" to set a theme just for CiviCRM.)

  4. At the bottom, click "Install". (Note: This may take a few moments to execute.)
Run installer via command-line

CiviCRM has a command-line administration tool, cv, which can perform installation. For details, see command-line installer.

Review the permissions

Drupal will create the /files/ directory (and make it writeable), but only when saving admin/settings. Same holds for /temp directory, and a /uploads/ directory in the CiviCRM module root. On a brand-new Drupal install, this directory may be missing. Even on an existing installation, if file permissions are not set properly, the directory may be missing. If enabling the CiviCRM module generates errors regarding the files directory, you must create it (writeable) manually.

  • Go to the CiviCRM dashboard to see the CiviCRM menus: (or if you don't have Clean URLs enabled)

  • Go to Administer » User management » Permissions

  • Verify that the Roles that you want to have access to CiviCRM have the appropriate permissions checked. CiviCRM is installed with a number of fixed permissions (such as "edit contacts" and "administer CiviCRM").

Permissions for the Anonymous Role

Many sites want anonymous visitors to have access to certain CiviCRM functionality. These permissions are enabled during installation for the Anonymous role. You should review them and modify if needed based on your requirements:

  • access all custom data : If you plan on collecting "custom" data from visitors in standalone forms or as they make a contribution - enable this permission.
  • access CiviMail subscribe/unsubscribe pages : If you are planning on using CiviMail, enable this permission to allow anonymous users to subscribe and unsubscribe from mailing lists via the web.
  • access uploaded files : If you plan on allowing visitors to upload or view photos or other files - enable this permission.
  • make online contributions : If you plan on soliciting online contributions from visitors, enable this permission for the "anonymous" role.
  • profile listings and forms : If you plan on collecting name and address or other information from visitors, enable this permission for the "anonymous" role.
  • view event info and register for events : If you plan to use CiviEvent and want to allow un-authenticated visitors to view event information and register for events online - enable these permissions for the "anonymous" role.
  • view event participants : Enable this permission to allow anonymous users to access participant listing pages for events.

Synchronize the users

Once installed, CiviCRM keeps your Drupal Users synchronized with corresponding CiviCRM contact records. The 'rule' is that there will be a matched contact record for each Drupal user record. Conversely, only contacts who are authenticated users of your site will have corresponding Drupal user records.

When CiviCRM is installed on top of an existing Drupal site, a special CiviCRM Administrative feature allows you to automatically create CiviCRM contacts for all existing Drupal users:

  • Login to your Drupal site with an administrator-level login
  • Click the CiviCRM link in the main navigation block
  • If your Drupal site makes use of the db_prefix setting (in settings.php), in the top bar click Administer » System Settings » CMS Database Integration , and update the box for the Drupal Users Table Name so that it includes the prefix.
  • Click Administer in the menu bar
  • Click Users and Permissions from the drop-down menu, then select Synchronize Users to Contacts

Review the checklist

The Configuration Checklist provides a convenient way to work through the settings that need to be reviewed and configured for a new site. You can link to this checklist from the installation success page and you can visit it at any time from Administer » Administration Console » Configuration Checklist.

Test-drive CiviCRM

There should now be a CiviCRM link in your Drupal menu. Click that link and the CiviCRM Menu, Shortcuts, Search and New Individual Blocks should appear. You can now explore CiviCRM end-user features and begin configuring CiviCRM for your site/organization needs.



If your MySQL database is hosted on a different machine than your web server, or if your host requires it, you can use TLS to encrypt the connection between the database and the web server.

Full instructions on installing drupal are out of scope for this guide, but one method is to install into a test database first without MySQL encryption and then move the database to the live server and update settings.php to enable MySQL encryption.

See TLS for MySQL for introductory concepts and the settings for the CiviCRM database. For the Drupal database you have several options for updating settings.php:

  1. The simplest, which doesn't require a client certificate, but doesn't verify the server certificate.

    $databases = array (
      'default' =>
      array (
        'default' =>
        array (
          'database' => 'drupal',
          'username' => 'dbuser',
          'password' => 'dbpassword',
          'host' => '',
          'port' => '',
          'driver' => 'mysql',
          'prefix' => '',
          'pdo' => array(
              PDO::MYSQL_ATTR_SSL_CA => TRUE,
  2. Verifies the server certificate, and doesn't require a client certificate.

    Host name must match certificate name

    Note that the DATABASE SERVER certificate would have to have a CN (common name field) that matches exactly the host you are using in $databases['default']['default']['host']. So if the host is, then that must be the name on the SERVER certificate.

    'pdo' => array(
        // A certificate authority bundle.
        // If you are using a self-signed server certificate in a development
        // or testing environment, then this would be the same as the server
        // certificate.
        PDO::MYSQL_ATTR_SSL_CA => '/path/to/ca.crt',
  3. Client certificate/key pair (not self-signed), and do not verify the server certificate.

    'pdo' => array(
        PDO::MYSQL_ATTR_SSL_KEY => '/path/to/your.key',
        PDO::MYSQL_ATTR_SSL_CERT => '/path/to/your.crt',
  4. Client certificate/key pair (could be self-signed), and verify the server certificate.

    'pdo' => array(
        // The SSL_CA can be the same as your.crt if self-signed, but note
        // that it would also have to be a certificate authority for the
        // server certificate. Self-signed would only be for local
        // development testing.
        PDO::MYSQL_ATTR_SSL_CA => '/path/to/ca.crt',
        PDO::MYSQL_ATTR_SSL_KEY => '/path/to/your.key',
        PDO::MYSQL_ATTR_SSL_CERT => '/path/to/your.crt',

Integration modules

Webform CiviCRM module

CiviCRM Entity module


  • Review the Troubleshooting page for help with problems you may encounter during the installation.