Project

General

Profile

Overrides for devstaging sites » History » Revision 3

Revision 2 (Jon Goldberg, 12/15/2014 07:00 PM) → Revision 3/4 (Morgan Robinson, 06/16/2020 01:37 PM)

h1. Handling CiviCRM on Overrides for dev/staging sites 

 h2. Moving the CiviCRM database 

 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. 

 * When syncing a civicrm database from its live server to a local or test server, the mysql user may Generally speaking, we should be different. You can identify the mysql user for both in the database connection string in civicrm.settings.php:  
 <pre> 
 cat civicrm.settings.php | grep mysql 
 </pre> 
 * 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:  
 <pre> 
 sed -i 's/`userlive`@`localhost`/`usertest`@`localhost`/g' ~/sql-dump/example_civi.sql 
 </pre> 


 h2. Resource URL overrides 

 In development and staging environments, you can override overriding certain CiviCRM options on dev/staging sites in civicrm.settings.php. Once overridden in this file, any resource URLs or other settings stored in civicrm.settings.php, so we can copy the database will not disrupt the site when the database is synced from the live site. between servers with impunity. 

 Example settings for paths below. These lines may go at the top of Here's my local CPEHN overrides.    You can put these into civicrm.settings.php on line 2, just under the opening PHP code tag, so they are obvious to other users. 

 @<?php@. 
 <pre> 
 global $civicrm_setting; 
 $civicrm_setting['CiviCRM Preferences']['allowPermDeleteFinancial'] = 1; 
 $civicrm_setting['Directory Preferences']['customTemplateDir'] = '/var/www/mysite/sites/all/civicrm/templates'; '/var/www/cpehn/sites/all/civicrm/templates'; 
 $civicrm_setting['Directory Preferences']['customPHPPathDir'] = '/var/www/mysite/sites/all/civicrm'; '/var/www/cpehn/sites/all/civicrm'; 
 $civicrm_setting['Directory Preferences']['extensionsDir'] = '/var/www/mysite/sites/all/civicrm/extensions'; '/var/www/cpehn/sites/all/civicrm/extensions'; 
 $civicrm_setting['URL Preferences']['extensionsURL'] = 'http://mysite.local/sites/all/civicrm/extensions/'; 'http://cpehn.local/sites/all/civicrm/extensions/'; 
 $civicrm_setting['URL Preferences']['imageUploadURL'] = 'http://mysite.local/sites/default/files/civicrm/persist/contribute/'; 'http://cpehn.local/sites/default/files/civicrm/persist/contribute/'; 
 $civicrm_setting['URL Preferences']['userFrameworkResourceURL'] = 'http://mysite.local/sites/all/modules/contrib/civicrm'; 'http://cpehn.local/sites/all/modules/contrib/civicrm'; 
 </pre> 

 It's also possible to override other values in the @Setting@ object in this file to facilitate development or testing. Note that "allowPermDeleteFinancial" overrides built-in CiviAccounts auditing, and shouldn't ever be enabled on production!
Go to top