Managing CiviCRM Paths and URLs on Pantheon

Last updated on
2 July 2020

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

Because of the dynamic nature of Pantheon hosting, paths should be configured in the civicrm.settings.php file. Support for overriding these CiviCRM settings with the civicrm.settings.php file is supported by CiviCRM, but requires some Pantheon specific code to use a dynamic value.

The civicrm.settings.php file is similar to Drupal's settings.php in that it is where settings CiviCRM needs are stored. Also like Drupal's settings.php, the civicrm.settings.php is normally created when installing CiviCRM based on values added to a form during the install process. When installing CiviCRM, the lack of a civicrm.settings.php causes CiviCRM to tell Drupal that not all dependencies have been met for CiviCRM to be installed. Because the CiviCRM Starter Kit install profile lists the CiviCRM "module" as a dependency, the CiviCRM Starter Kit install cannot continue until CiviCRM is installed. The result is this screen:

Depending on the environment, once the CiviCRM is install is complete the Drupal install will resume where you've left off or start over (Pantheon starts over).

Once the civicrm.settings.php file is created, it can not be modified by updates to CiviCRM in the CiviCRM Starter Kit. You can update the code/sites/default/civicrm.settings.php file manually using SFTP or Git on the Dev instance of the site. Because Pantheon considers these settings files code, the same file settings.php and civicrm.settings.php files are pushed to the Test and Live instances. Because of this, Pantheon specific code is included in the civicrm.settings.php along with the normal CiviCRM settings. Instead of using hard coded settings, in a Pantheon environment the settings are pulled from $_ENV.

To update your settings file the easiest is to copy sites/default/default.civicrm.settings.php and use it as a new civicrm.settings.php file. Go through it, update %siteKey% with CIVICRM_SITE_KEY from the old settings file. CIVICRM_UF_BASEURL will get set automatically but if you're having problems with it you can set it manually.

MOVING CIVICRM DIRECTORIES TO PRIVATE FILES ON PATHEON

Recently, CiviCRM began recommending adding an .htaccess file to protect specific directories. Because Pantheon uses Nginx, that is not possible. Instead, the directories you want protected from direct access must be moved to the private files directory. New installs of the CiviCRM StarterKit on Pantheon now place the directories there by default, but it is not possible to move the directory in an update hook. This must been done manually before updating the settings in civicrm.settings.php.

To move the directories, do the following:

  1. Make sure you've copied default.civicrm.settings.php to civicrm.settings.php and copied over any customizations.
  2. On your local computer, on your desktop, create an empty folder called "private". You need to create the directory on your local computer rather than directly on the pantheon server or you will get a permissions error.
  3. Switch your pantheon environment dashboard to SFTP mode and SFTP into your pantheon environment. Browse to files > civicrm. Drag your "custom" and "uploads" folders into the "private" folder that you created on your desktop.
  4. Delete the "custom" and "uploads" folders from the current location on pantheon.
  5. In your SFTP client, browse to "files". Drag the "private" folder from your desktop into the SFTP window to upload it. The new location will now be "files" > "private" > "custom" and "files" > "private" > "upload".
  6. Go to CiviCRM > Administration > System Settings > Directories, double check that the new settings are showing up, and resave the page. If there are any issues, you can first make sure you've cleared your CiviCRM caches at CiviCRM > Administration > System Settings > Cleanup Caches and Update Paths.

Help improve this page

Page status: No known problems

You can: