Project

General

Profile

Overrides for devstaging sites » History » Version 3

Morgan Robinson, 06/16/2020 01:37 PM
adding instructions for Civi database

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
17
h2. Resource URL overrides
18
19
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.
20
21
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.
22
23
<pre>
24 1 Jon Goldberg
global $civicrm_setting;
25 3 Morgan Robinson
$civicrm_setting['Directory Preferences']['customTemplateDir'] = '/var/www/mysite/sites/all/civicrm/templates';
26
$civicrm_setting['Directory Preferences']['customPHPPathDir'] = '/var/www/mysite/sites/all/civicrm';
27
$civicrm_setting['Directory Preferences']['extensionsDir'] = '/var/www/mysite/sites/all/civicrm/extensions';
28
$civicrm_setting['URL Preferences']['extensionsURL'] = 'http://mysite.local/sites/all/civicrm/extensions/';
29
$civicrm_setting['URL Preferences']['imageUploadURL'] = 'http://mysite.local/sites/default/files/civicrm/persist/contribute/';
30
$civicrm_setting['URL Preferences']['userFrameworkResourceURL'] = 'http://mysite.local/sites/all/modules/contrib/civicrm';
31 1 Jon Goldberg
</pre>
32
33 3 Morgan Robinson
It's also possible to override other values in the @Setting@ object in this file to facilitate development or testing.
Go to top