One of the common workflows we see among professional developers and students is to create a new Drupal 8 site on Pantheon, then clone the site down to a local machine and get it up-and-running in Acquia Dev Desktop (with a fresh, empty database).
Unfortunately, there's usually a little "trick" involved in getting the Drupal 8 site to install cleanly locally, that involves a Drupal core security mechanism. Drupal core provides the opportunity to set a "hash salt" variable in the settings.php file. This variable is used for creating secure sessions and one-time login links. Pantheon injects the "hash salt" value automatically (which is a good thing, security-wise), but the downside of this is that when the site is moved to a local environment, Pantheon's "hash salt" injection isn't available.
The "hash salt" variable doesn't have to be the same on local and Pantheon, so we can easily set a new one on local. If the "hash salt" isn't set on local prior to installation, then the install will fail.
So, to install a cloned Pantheon Drupal 8 site on a local machine using Acquia Dev Desktop (or pretty much any other *AMP stack), we use the following steps:
- Clone the repository.
- Copy sites/example.settings.local.php to sites/default/settings.local.php (ensure this file is .gitignored).
- Add the following to the bottom of sites/default/settings.local.php:
$settings['hash_salt'] = 'some_random_string';(note that it cannot be an empty string!).
- (Acquia Dev Desktop) Import new local site.
- Run the Drupal installer.
If you forget to add the "hash salt" stuff prior to running the installer, you'll likely have to manually empty the database and start all over again...
Thanks for the info about "hash salt." However, I got the following trying to import a pantheon site into DevDesktop. I DID create the database from an sql dump file, but not sure why that would cause any problem.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
When I tried to apply this protocol to my Drupal 8 download from Pantheon, I had a GIT clone of files and a database SQL dump. So I ran DevDesktop
"Import from existing site" with create database from database dump file. The 'hash_salt' setting saved me from getting the first error that I had
when I hadn't used it. But the installation gave me a Server Error. I had to set: $settings['update_free_access'] = TRUE; at the bottom of
settings.local.php in order to run update.php on the site. That seemed to fix whatever issues were causing the Server error.
This was very helpful. Thanks Mike!
Running the following from source root before importing site and database has worked for me:
$ cp sites/example.settings.local.php sites/default/settings.local.php
$ printf "\n\n/** Need this to make Acquia Dev Desktop working **/\n\$settings['hash_salt'] = 'mysalt';\n\$settings['update_free_access'] = TRUE;\n\n" >> sites/default/settings.local.php