Overrides for devstaging sites » History » Version 4
Manu Mei-Singh, 03/25/2024 07:36 PM
1 | 3 | Morgan Robinson | h1. Handling CiviCRM on dev/staging sites |
---|---|---|---|
2 | 1 | Jon Goldberg | |
3 | 3 | Morgan Robinson | h2. Moving the CiviCRM database |
4 | 1 | Jon Goldberg | |
5 | 3 | Morgan Robinson | CiviCRM database dumps contain @DEFINER@ statements that specify a mysql user for the purpose of creating triggers. If the database is loaded from live with an incorrect user, the dev/staging site may not work correctly and backups will not run. |
6 | |||
7 | * When syncing a civicrm database from its live server to a local or test server, the mysql user may be different. You can identify the mysql user for both in the database connection string in civicrm.settings.php: |
||
8 | 1 | Jon Goldberg | <pre> |
9 | 3 | Morgan Robinson | cat civicrm.settings.php | grep mysql |
10 | </pre> |
||
11 | * If the users in the two environments are different, before loading a dump from live you can replace the DEFINER @`userlive`@@@`localhost`@ with @`usertest`@@@`localhost`@ in the database dump file: |
||
12 | <pre> |
||
13 | sed -i 's/`userlive`@`localhost`/`usertest`@`localhost`/g' ~/sql-dump/example_civi.sql |
||
14 | </pre> |
||
15 | |||
16 | 4 | Manu Mei-Singh | You can also remove the DEFINER lines using. Although you want to save the original |
17 | <pre><code class="bash"> |
||
18 | $: sed 's/\sDEFINER=[^`]*`@`[^`]*//g' -i sql_dumpfile.sql |
||
19 | </code></pre> |
||
20 | |||
21 | 3 | Morgan Robinson | |
22 | h2. Resource URL overrides |
||
23 | |||
24 | In development and staging environments, you can override CiviCRM options on dev/staging sites in civicrm.settings.php. Once overridden in this file, any resource URLs or other settings stored in the database will not disrupt the site when the database is synced from the live site. |
||
25 | |||
26 | Example settings for paths below. These lines may go at the top of civicrm.settings.php just under the opening PHP code tag, so they are obvious to other users. |
||
27 | |||
28 | <pre> |
||
29 | 1 | Jon Goldberg | global $civicrm_setting; |
30 | 3 | Morgan Robinson | $civicrm_setting['Directory Preferences']['customTemplateDir'] = '/var/www/mysite/sites/all/civicrm/templates'; |
31 | $civicrm_setting['Directory Preferences']['customPHPPathDir'] = '/var/www/mysite/sites/all/civicrm'; |
||
32 | $civicrm_setting['Directory Preferences']['extensionsDir'] = '/var/www/mysite/sites/all/civicrm/extensions'; |
||
33 | $civicrm_setting['URL Preferences']['extensionsURL'] = 'http://mysite.local/sites/all/civicrm/extensions/'; |
||
34 | $civicrm_setting['URL Preferences']['imageUploadURL'] = 'http://mysite.local/sites/default/files/civicrm/persist/contribute/'; |
||
35 | $civicrm_setting['URL Preferences']['userFrameworkResourceURL'] = 'http://mysite.local/sites/all/modules/contrib/civicrm'; |
||
36 | 1 | Jon Goldberg | </pre> |
37 | |||
38 | 3 | Morgan Robinson | It's also possible to override other values in the @Setting@ object in this file to facilitate development or testing. |