CiviCRM for Drupal 8 installation notes » History » Version 22
Jon Goldberg, 07/16/2019 01:15 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 | 21 | Jon Goldberg | * If you do this, see also how to enable [Views integration on D8 with separated databases](https://civicrm.stackexchange.com/a/31146/12). |
17 | 1 | Jon Goldberg | |
18 | 17 | Jon Goldberg | #### extern directory access |
19 | 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: |
||
20 | ``` |
||
21 | # For security reasons, deny access to other PHP files on public sites. |
||
22 | # Note: The following URI conditions are not anchored at the start (^), |
||
23 | # because Drupal may be located in a subdirectory. To further improve |
||
24 | # security, you can replace '!/' with '!^/'. |
||
25 | # Allow access to PHP files in /core (like authorize.php or install.php): |
||
26 | RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$ |
||
27 | # Allow access to test-specific PHP files: |
||
28 | RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php |
||
29 | # Allow access to Statistics module's custom front controller. |
||
30 | # Copy and adapt this rule to directly execute PHP files in contributed or |
||
31 | # custom modules or to run another PHP application in the same directory. |
||
32 | RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$ |
||
33 | # Deny access to any other PHP files that do not match the rules above. |
||
34 | # Specifically, disallow autoload.php from being served directly. |
||
35 | RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F] |
||
36 | ``` |
||
37 | Change it to this: |
||
38 | ``` |
||
39 | # For security reasons, deny access to other PHP files on public sites. |
||
40 | # Note: The following URI conditions are not anchored at the start (^), |
||
41 | # because Drupal may be located in a subdirectory. To further improve |
||
42 | # security, you can replace '!/' with '!^/'. |
||
43 | # Allow access to PHP files in /core (like authorize.php or install.php): |
||
44 | RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$ |
||
45 | # Allow access to test-specific PHP files: |
||
46 | RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php |
||
47 | # Allow access to Statistics module's custom front controller. |
||
48 | # Copy and adapt this rule to directly execute PHP files in contributed or |
||
49 | # custom modules or to run another PHP application in the same directory. |
||
50 | RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$ |
||
51 | # Allow access to the CiviCRM "extern" directory. |
||
52 | RewriteCond %{REQUEST_URI} !/libraries/civicrm/extern/[a-z]+\.php$ |
||
53 | # Deny access to any other PHP files that do not match the rules above. |
||
54 | # Specifically, disallow autoload.php from being served directly. |
||
55 | RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F] |
||
56 | ``` |
||
57 | |||
58 | 22 | Jon Goldberg | #### KCFinder PHP access |
59 | |||
60 | **Note: I needed to do this on one site and not another. Anyone who can provide me with insight as to why it's not always necessary, I'd really appreciate it!** |
||
61 | |||
62 | As above, but add the following condition as well (place anywhere above the `RewriteRule` in the block above: |
||
63 | ``` |
||
64 | # Allow access to CKEditor for CiviCRM. |
||
65 | RewriteCond %{REQUEST_URI} !/libraries/civicrm/packages/kcfinder/[a-z_/]+\.php$ |
||
66 | ``` |
||
67 | |||
68 | 15 | Jon Goldberg | ### On every install and update: |
69 | |||
70 | 1 | Jon Goldberg | #### non-bootstrap scripts |
71 | |||
72 | 13 | Jon Goldberg | [There's an [open MR](https://gitlab.com/roundearth/civicrm-composer-plugin/merge_requests/4) to handle this] |
73 | 8 | Jon Goldberg | |
74 | 20 | Jon Goldberg | * To get `bin/csv/import.php` loading correctly, create a *second* `settings_location.php` in `vendor/civicrm/civicrm-core`: |
75 | 13 | Jon Goldberg | |
76 | ```php |
||
77 | 1 | Jon Goldberg | <?php |
78 | 8 | Jon Goldberg | |
79 | 16 | Jon Goldberg | define('CIVICRM_CONFDIR', dirname(dirname(dirname(dirname(__FILE__)))) . '/web/sites'); |
80 | 1 | Jon Goldberg | ``` |