Project

General

Profile

CiviCRM for Drupal 8 installation notes » History » Version 18

Jon Goldberg, 05/03/2019 07:10 PM

1 5 Jon Goldberg
{{last_updated_at}} by {{last_updated_by}}
2 1 Jon Goldberg
# CiviCRM for Drupal 8 installation notes
3
4 8 Jon Goldberg
* Make sure your composer version is up to date!  The one that ships with civicrm-buildkit is quite old.
5
* Run the composer command on [David Snopek's blog post](https://www.mydropwizard.com/blog/better-way-install-civicrm-drupal-8) that fits your scenario (creating a new site vs. adding Civi to an existing D8 site).
6
 * New site is: `composer create-project roundearth/drupal-civicrm-project:8.x-dev some-dir --no-interaction`
7
* Add the following to `civicrm.settings.php` (modify the last line for your actual CMS root, and paste this after `CIVICRM_UF_BASEURL` is defined):
8 1 Jon Goldberg
9 8 Jon Goldberg
```php
10
$civicrm_setting['URL Preferences']['userFrameworkResourceURL'] = CIVICRM_UF_BASEURL . '/libraries/civicrm/';                                                                                                     
11
$civicrm_paths['civicrm.root']['url'] = CIVICRM_UF_BASEURL . '/libraries/civicrm/';
12
$civicrm_setting['domain']['userFrameworkResourceURL'] = CIVICRM_UF_BASEURL . '/libraries/civicrm/';
13
$civicrm_paths['cms.root']['path'] = '/home/jon/local/drupal8test/web';
14 2 Jon Goldberg
```
15 8 Jon Goldberg
* If you prefer separate Drupal and Civi databases, [dump the Civi tables only](https://stackoverflow.com/a/5269543/2832108) and [drop the Civi tables](https://stackoverflow.com/a/1589324/2832108).  Load them into a new database and modify your `CIVICRM_DSN` in `civicrm.settings.php` accordingly.
16 1 Jon Goldberg
17 17 Jon Goldberg
#### extern directory access
18
D8 restricts access to PHP files that aren't whitelisted, so you need to whitelist the `extern` directory files.  In `<webroot>/.htaccess`, find this rule:
19
```
20
# For security reasons, deny access to other PHP files on public sites.
21
  # Note: The following URI conditions are not anchored at the start (^),
22
  # because Drupal may be located in a subdirectory. To further improve
23
  # security, you can replace '!/' with '!^/'.
24
  # Allow access to PHP files in /core (like authorize.php or install.php):
25
  RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
26
  # Allow access to test-specific PHP files:
27
  RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php
28
  # Allow access to Statistics module's custom front controller.
29
  # Copy and adapt this rule to directly execute PHP files in contributed or
30
  # custom modules or to run another PHP application in the same directory.
31
  RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
32
  # Deny access to any other PHP files that do not match the rules above.
33
  # Specifically, disallow autoload.php from being served directly.
34
  RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]
35
```
36
Change it to this:
37
```
38
  # For security reasons, deny access to other PHP files on public sites.
39
  # Note: The following URI conditions are not anchored at the start (^),
40
  # because Drupal may be located in a subdirectory. To further improve
41
  # security, you can replace '!/' with '!^/'.
42
  # Allow access to PHP files in /core (like authorize.php or install.php):
43
  RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
44
  # Allow access to test-specific PHP files:
45
  RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php
46
  # Allow access to Statistics module's custom front controller.
47
  # Copy and adapt this rule to directly execute PHP files in contributed or
48
  # custom modules or to run another PHP application in the same directory.
49
  RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
50
  # Allow access to the CiviCRM "extern" directory.
51
  RewriteCond %{REQUEST_URI} !/libraries/civicrm/extern/[a-z]+\.php$
52
  # Deny access to any other PHP files that do not match the rules above.
53
  # Specifically, disallow autoload.php from being served directly.
54
  RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]
55
```
56
57 15 Jon Goldberg
### On every install and update:
58
59 8 Jon Goldberg
#### kcfinder
60
61 13 Jon Goldberg
[Note there is an [merged MR](https://gitlab.com/roundearth/civicrm-composer-plugin/merge_requests/2) to handle the first two steps in `civicrm-composer-plugin` but it's not published to packagist yet.  The third step should be included in Civi 5.13.]
62 8 Jon Goldberg
kcfinder (image browsing/upload within CKEditor) is currently broken.  You need to do several things to fix.
63 1 Jon Goldberg
* First, copy it to libraries/civicrm: `cp -r vendor/civicrm/civicrm-core/packages/kcfinder web/libraries/civicrm/packages/`.
64 13 Jon Goldberg
* Your `<webroot>/libraries/civicrm/settings_location.php` should read:
65
66
```php
67
<?php
68
69 16 Jon Goldberg
define('CIVICRM_CONFDIR', dirname(dirname(dirname(__FILE__))) . '/sites');
70 13 Jon Goldberg
```
71
72 1 Jon Goldberg
#### non-bootstrap scripts
73
74 13 Jon Goldberg
[There's an [open MR](https://gitlab.com/roundearth/civicrm-composer-plugin/merge_requests/4) to handle this]
75 8 Jon Goldberg
76 13 Jon Goldberg
* To get `extern` scripts and `bin/csv/import.php` loading correctly, create a *second* `settings_location.php` in `vendor/civicrm/civicrm-core`:
77
78
```php
79 1 Jon Goldberg
<?php
80 8 Jon Goldberg
81 16 Jon Goldberg
define('CIVICRM_CONFDIR', dirname(dirname(dirname(dirname(__FILE__)))) . '/web/sites');
82 1 Jon Goldberg
```