Drupal Enterprise 7: Setting Up a Local Environment Using Acquia Dev Desktop 2

This article describes how to set up Drupal Enterprise 7 local environments for development work using Acquia Dev Desktop.

These instructions are only for those using Drupal Enterprise 7. 

In the instructions below please replace:

  1. your-site-name with the name of your site
  2. your-internet-id with your internet id
  3. your-site-github-url with the SSH GitHub URL of your site's repository

Instructions

You'll need:

  1. an existing site in the platform
  2. a GitHub repository with your site code
  3. a copy of Acquia Dev Desktop 2
  4. a copy of your site's database
  5. a copy of your site's files (optional)

Install Acquia Dev Desktop

Download and follow the standard installation instructions for Acquia Dev Desktop 2. For Windows, make sure you install it in a location where it doesn't run as administrator e.g. C:\Users\your-internet-id\.

Get the platform code

  1. Pick a location for your local site and clone the repository:

    git clone [email protected]:drupalplatform/umnstandard.git your-site-name

    This will create a directory at that location.

  2. The default branch for the platform code is umn-production, which is the production branch. If you need the development/stage branch:

    cd your-site-name

    git checkout profiles-stage

 

Add sites/default directory

  1. Change to the sites directory:

    cd your-site-name/docroot/sites
  2. Remove the default directory, if there is one:

          rm -rf default

      3. Clone your site repository into default:

          git clone your-site-github-url default

      4. If you need a different branch than the default one:

          cd default
          git checkout branch-name

      5. For sites that have already launched, create a symbolic link from your site's production hostname to the default directory:

          Mac:

          ln -s default/ your-site-name

          Windows(run the terminal as administrator):

          mklink /D your-site-name C:\Users\your-internet-id\DevDesktop\your-site-name\docroot\sites\default

Obtain the site database

You can donwload a copy of your database at drupalmanagement.umn.edu. Login with your internet id and password, select your web site and click the Download button.

To Dev Desktop!

  1. Open Acquia Dev Desktop.
  2. Click the plus sign in the lower left and select Import local Drupal site.
  3. For Local codebase folder, select the docroot folder of the local site
  4. For Local site name enter your-site-name
  5. Set Use PHP to version 7.1.x.
  6. For Database select Start with MySQL database dump file.
  7. For Dump file Select the database .sql file you downloaded and unzipped eariler.
  8. Click OK.
  9. Wait for the site to finish importing.
  10. With the newly created site selected, click More and choose Open console.
  11. Run

    drush rr

    If you get a "The drush command 'rr' could not be found" error message, run the command below, then try again:

    drush @none dl registry_rebuild-7.x

  12. Switch to your site's default directory and adjust settings using drush:

    drush ev "variable_set('file_public_path', 'sites/default/files'); variable_set('file_temporary_path', '/tmp'); registry_rebuild(); drupal_flush_all_caches();"

  13. Disable some modules with this command: 

    drush dis -y securepages umn_user umn_single_site_alert expire simplesamlphp_auth acquia_purge acquia_connector acquia_agent acquia_spi domain_301_redirect

  14. Reset the password on your account so you can login: 

    drush upwd --password="somestrongpasswordhere" your-internet-iD

To login into the site through the UI using Drupal authentication go to https://your-site-name.dd:8083/user.

To login as user1 run

drush --uri="your-site-name.dd:8083" uli

Copy files from existing environment

If your site already has files (e.g., image assets), you may want to include those locally. To get a copy of your site's files, email [email protected]. To include the files:

  1. make a files directory in the docroot/sites/default directory
  2. copy the site files you received to the files directory

As an alternative, you can use the Stage File Proxy module, which sends requests from your local files directory to the production environment and makes a copy of the production file in your local site.

Enable and Configure Stage File Proxy

  1. make a files directory in the docroot/sites/default directory
  2. at docroot run:

drush en -y stage_file_proxy
drush vset stage_file_proxy_origin "http://your-site-name.umn.edu"
drush vset stage_file_proxy_origin_dir "sites/your-site-name.umn.edu"

Clean up settings.php

When Dev Desktop creates your site, it appends some code to your site's settings.php file. If this code makes it up to the platform it will break your site. Perhaps the easiest way to deal with this is by moving the changes from settings.php to a settings.local.php file, while ensuring settings.local.php file doesn't make it up to the repository.

In a terminal:

  1. cd docroot/sites/default
  2. Stash the local changes with git stash
  3. Edit your .gitignore file to include settings.local.php
  4. Create the settings.local.php file in your local sites/default folder
  5. Remove the lines below from settings.php and add them to settings.local.php
  6. Add, commit, and push your updated .gitignore file to the remote repository

<?php
//<DDSETTINGS>
// Please don't edit anything between <DDSETTINGS> tags.
// This section is autogenerated by Acquia Dev Desktop.
if (isset($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR']) && file_exists($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] . '/loc_your-site-name_dd.inc'))
 require($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] . '/loc_your-site-name_dd.inc');
//</DDSETTINGS>

 Note: The files with the DB settings will be at

  • Mac: /Users/your-internet-id/.acquia/DevDesktop/DrupalSettings/loc_your-site-name_dd.inc
  • Windows: C:\Users\your-internet-id\.acquia\DevDesktop\DrupalSettings\loc_your-site-name_local.inc

How to pull/push from repositories

  • To update your local repository with new platform code run

    git pull

    in the your-site-name directory
  • To push changes from the local repository to the remote site repository run

    git push origin [branch_name]

    in the default directory

Additional information

If you encounter errors while attempting these steps, please join the Drupal team at the Drupal Working Lab or send an email to [email protected] for further assistance.