7 Setting up CiviCRM
Theodotos Andreou edited this page 2018-01-16 13:42:24 +02:00

Next we need to setup CiviCRM alongside Drupal 7.

Prerequisites

Prepare CiviCRM requirements

Install the PHP SOAP extension

$ sudo apt -y install php7.0-soap

Set the PHP memory_limit to 256M:

sudo sed -i -e 's/memory_limit\ =\ 128M/memory_limit\ =\ 256M/' /etc/php/7.0/fpm/php.ini

Restart php7.0-fpm:

sudo systemctl restart php7.0-fpm

Prepare a *CiviCRM Database:

MariaDB [(none)]> CREATE DATABASE civicrm CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON civicrm.* TO 'cmsuser'@'localhost' IDENTIFIED BY 'MyDrupalDBPass';
MariaDB [(none)]> FLUSH PRIVILEGES;

Install CiviCRM

Download and extract civicrm:

$ sudo su - webadmin
$ wget https://download.civicrm.org/civicrm-4.7.29-drupal.tar.gz
$ tar xvzf civicrm-4.7.29-drupal.tar.gz -C cms/sites/all/modules/

Setup the correct permissions (as the admin user):

$ sudo chown -R www-data:webadmin /srv/webadmin/cms/sites/default
$ sudo chmod g+w /srv/webadmin/cms/sites/default

Run the installer:

https://cms.example.com/sites/all/modules/civicrm/install/index.php

Fill in these settings:

  • CiviCRM Database Settings

    • MySQL server: localhost
    • MySQL username: cmsuser
    • MySQL password: *MyDrupalDBPass
    • MySQL database: civicrm
  • Drupal Database Settings

    • MySQL server: localhost
    • MySQL username: cmsuser
    • MySQL password: *MyDrupalDBPass
    • MySQL database: cms

Then press the 'Re-check Requirements' button. If you get the green assurance that all is OK proceed by pressing the 'Check Requirements and Install CiviCRM' button.

Post-install steps

Setup cron

Under the root user run crontab -e and add this cronjob:

5 * * * * php /srv/webadmin/cms/sites/all/modules/civicrm/bin/cli.php -u cmsadmin -p MyDrupalAdminPass -e Job -a execute

Restrict access to private files

Add the following configuration in /etc/nginx/sites-available/cms:

        location ~ ^/sites/.*/files/civicrm/(ConfigAndLog|upload|templates_c|custom) {
                 deny all;
        }

Restart Nginx:

$ sudo nginx -t && sudo systemctl restart nginx

Set Drupal Views to use the CiviCRM database

Visit this URL:

https://cms.example.com/civicrm/admin/setting/uf?reset=1

Add the following:

  • Drupal Users Table Name: users
  • Sync CMS Email: Enabled

Before we finish, click the "System Status: Error" link at the bottom of the CiviCRM and look for errors or warnings.

References