Drupal Enterprise: Setting Up a Local Environment Using Acquia Dev Desktop 2
This article describes how to set up local environments for development work using Acquia Dev Desktop.
- an existing site in the platform
- a GitHub repository with your site code
- a copy of Acquia Dev Desktop 2
- a copy of your site’s database
- a copy of your site’s files
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\myInternetId\.
Place platform code
Pick where you would like to store the site on your computer, e.g ~/Sites, and clone the repository there
git clone firstname.lastname@example.org:drupalplatform/umnstandard.git example
This will create a example folder at that location.
Add sites/default directory
Change to the sites directory for your site:
Clone your site code repository into a default directory:
git clone email@example.com:ExampleOrg/ExampleSite.git default
For sites that have already launched, create a symbolic link from your site's production hostname to the default directory:
ln -s default/ example.umn.edu on the Mac
mklink /D example.umn.edu C:\Users\myInternetId\DevDesktop\example\sites\default on Windows (run the terminal as administrator)
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 firstname.lastname@example.org. To include the files:
- make a files directory in the docroot/sites/default directory
- copy the site files you received to the files directory
Obtain the site database
- Contact email@example.com to obtain a copy of your site’s database. Tier2 will generally store it in a NetFiles account.
- Download the database zip file.
- Unzip the downloaded database once the download has completed.
Finally, to Dev Desktop!
- Open Acquia Dev Desktop.
- Close any nuisance window that may appear on startup.
- Click the plus sign in the lower left and select Import local Drupal site.
- For the Local codebase folder, select the ‘docroot’ folder in the location you initially cloned the repository to e.g /Users/myInternetId/Sites/example/docroot
- Set Use PHP to version 5.5.x.
- For Database select Start with MySQL database dump file.
- For Dump file Select the database you downloaded and unzipped eariler.
- Click OK.
- Wait for the site to finish importing.
- With the newly created site selected, click More and choose Open console.
- 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
- Reset the password on your account so you can login: drush upwd --password="somestrongpasswordhere" myInternetID
Note: When logging into a site locally, use example.umn.edu/user, rather than example.umn.edu/saml_login.
Adjust some settings, clear some cache with drush
Switch to your site’s default directory and evaluate some PHP using drush:
drush ev "variable_set('file_public_path', 'sites/default/files'); variable_set('file_temporary_path', '/tmp'); registry_rebuild(); drupal_flush_all_caches();"
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 using a settings.local.php file with that code and removing the changes from settings.php while ensuring your settings.local.php file doesn't make it up to the repository.
So, in a terminal:
- Make sure you're in the right directory: cd /Users/myInternetId/Sites/DevDesktop/example/sites/default
- Stash the Dev Desktop changes: git stash
- Edit your .gitignore file to include the following line: settings.local.php
- Add, commit, and push your updated .gitignore file to whatever branches you like.
- Create the settings.local.php file in your sites/default folder
- Remove the lines below from settings.php and ad them to settings.local.php (replacing _example_ in two places with the name of the site used to create the Dev Desktop site; generally, this will be the subdomain part of the hostname, e.g., example from example.umn.edu)
// 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_example_dd.inc'))
require($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] . '/loc_example_dd.inc');
Note: The files with the DB settings will be at
- Mac: /Users/myInternetId/.acquia/DevDesktop/DrupalSettings/loc_example_dd.inc
- Windows: C:\Users\myInternetId\.acquia\DevDesktop\DrupalSettings\loc_mywebsite_local.inc
How to pull/push from repositories
- To update your local repository with new platform code run git pull in the example directory
- To push changes from the local repository to the remote site repository run git push origin [branch_name] in the default directory