Skip to content Skip to navigation

Create a Development Drupal Environment

Posted by: 

These instructions describe how to set up a development copy of your live Drupal site within the Stanford web environment.

  1. Create a new database (at https://tools.stanford.edu/cgi-bin/sumysql/sumysql). This will give you a database user name and password, stored in a file at /afs/ir/group/mygroup/db_private/db_info
  2. SSH into corn
    ssh sunetid@corn.stanford.edu

    Enter your password when prompted
  3. Change into the production Drupal directory
    cd /afs/ir/group/mygroup/cgi-bin/drupal
  4. Create a dump file of the database
    drush sql-dump --result-file=dbdump.sql
  5. Move up one directory
    cd ..
  6. Make a copy of the production directory
    cp -r drupal drupal-dev
  7. Move into the development directory
    cd drupal-dev
  8. Edit the .htaccess file; you want to change the line that starts with "RewriteBase" so that it reflects the new development directory
    RewriteBase /group/mygroup/cgi-bin/drupal-dev
  9. Edit the settings.php file (usually in sites/default) to point to your new, development database
    Drupal 6
      $db_url = 'mysqli://newusername:newpassword@127.0.0.1/newdatabasename';
     
    Drupal 7
    $databases = array (
      'default' =>  
      array (
        'default' =>  
        array (
          'database' => 'newdatabasename',
          'username' => 'newusername',
          'password' => 'newpassword',
          'host' => '127.0.0.1',
          'port' => '', 
          'driver' => 'mysql',
          'prefix' => '', 
        ),  
      ),  
    );
  10. (If applicable) Comment out the line that starts with $base_url in sites/default/settings.php:
    // $base_url = 'https://myvanityurl.stanford.edu'; // NO trailing slash!
  11. Populate the new database from your database dump file
    mysql -f -u username -ppassword -h 127.0.0.1 databasename < dbdump.sql
  12. (If applicable) Disable the Reverse Proxy module
    drush -y dis reverse_proxy
  13. Visit your site at http://www.stanford.edu/group/mygroup/cgi-bin/drupal-dev. (Note: the WebAuth Module for Drupal (WMD) may not work on the development site.)
  14. Remember to delete your database dumps (dbdump.sql) from the Drupal directory in both the production and development Drupal installs. These should not be web-accessible.