Install CiviCRM on Drupal 7
About this document
This guide covers standard installation of CiviCRM on an existing Drupal 7 site. It assumes that you previously completed these tasks:
Alternative: Civibuild for developers
Get the code¶
The CiviCRM download page provides a pre-built archive for use with Drupal 7. A
typical archive file is ~20mb and looks like
civicrm-X.Y.Z-drupal.tar.gz. It contains a folder named
In Drupal 7, there is a folder for storing add-on modules:
Our goal is to download the archive and extract into this folder. Here are a few example ways to download and extract:
Download via web-browser
This method does not require shell access on the server. You may adapt based your server's arrangement.
- On the CiviCRM download page, click the link for CiviCRM / Drupal 7. Save the file locally.
- Extract the archive locally. For example, in a Linux workstation, one might say:
cd ~/Downloads tar xvzf civicrm-X.Y.Z-drupal.tar.gz
- Observe the new folder
- Using your favor file-transfer system (SSH/SFTP,
mv, etc), transfer the
Download via curl + tar
This method require shell access to the Drupal server.
- On the CiviCRM download page, note the current version.
- In the shell, navigate to the Drupal module folder (adjust as appropriate):
- In the shell, run the
tarcommands. Adjust the version
X.Y.Zto the appropriate value.
curl -L "https://download.civicrm.org/civicrm-X.Y.Z-drupal.tar.gz" | tar xvz
Download via Drupal web UI
This is the easiest way for a new administrator. However, it may not work in all deployments or all versions. For example, if the Drupal server has a locked-down configuration, then it may encounter permission errors or timeouts. The only way to find out is to try.
- On the CiviCRM download page, right-click the link for CiviCRM / Drupal 7. Copy the URL.
- Login to your Drupal site with administrator permissions.
- Navigate to Modules >> Install new module.
- Paste the URL
- Click "Install"
This may not work with CiviCRM 5.13-5.30
In CiviCRM versions 5.13 - 5.30, the prebuilt tarball included a symlink which is not accepted by the Drupal 7 installer. This should work again in 5.31.
The "Upload"/"Browse" option is unlikely to work.
The Install new module page provides another option for uploading the archive from your local computer. In a default PHP configuration, the upload limits are too conservative to accept the CiviCRM archive.
In all cases, the final outcome should be the creation of a new folder
Get the translations¶
The basic CiviCRM release includes support for US English (
en_US). To use another language or dialect, please download and extract the translation files.
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 7 web UI
- Enable the "CiviCRM" module
- Login to your Drupal site with administrator permissions.
- Navigate to the "Modules" page (
- Find "CiviCRM" and enable it.
- At the bottom, click "Save Configuration".
After enabling, the status message will display a link to "configure CiviCRM". Click it.
What if I didn't notice the link?
Use the URL bar. Navigate to the
The CiviCRM installer will open.
- If there are unmet requirements, the installer will list them. Consult the Requirements documentation for additional advice.
- If all the requirements are met, proceed through the brief questionnaire.
- If you have a separate MySQL database for CiviCRM, then locate "Environment: CiviCRM Database". Click the edit icon and enter the database URL.
- Finally, click "Install CiviCRM".
Run installer via the command-line
CiviCRM has a command-line administration tool,
cv, which can perform installation. For details, see command-line installer.
Review the permissions¶
Note that Drupal tries to 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:
https://example.org/index.php?q=civicrmif you don't have Clean URLs enabled)
Go to Administer » User management » Permissions
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
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.
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.
TLS for MySQL¶
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:
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' => 'db435.examplehost.com', 'port' => '', 'driver' => 'mysql', 'prefix' => '', 'pdo' => array( PDO::MYSQL_ATTR_SSL_CA => TRUE, PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => FALSE, ), ), ), );
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
hostyou are using in
$databases['default']['default']['host']. So if the host is
db435.examplehost.com, 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', ),
Client certificate/key pair (not self-signed), and do not verify the server certificate.
'pdo' => array( PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => FALSE, PDO::MYSQL_ATTR_SSL_KEY => '/path/to/your.key', PDO::MYSQL_ATTR_SSL_CERT => '/path/to/your.crt', ),
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', ),