Skip to content Skip to navigation

Create a Local Development Installation

Posted by: 
Topics: 

You have a Drupal installation up and running on an AFS Group space. It sure would be nice to have a copy of your Drupal site somewhere that you could experiment on, now wouldn't it? (Of course, most people would have done this as a very first step, but if you were most people, you wouldn't be needing this guide, now would you?)

What You'll Need

  • A Macintosh computer running a relatively recent version of OS X (these instructions are based on OS 10.4.11)
  • An Internet connection
  • Access to your Drupal files

Step 1: MAMP

MAMP stands for "Macintosh Apache MySQL PHP". It's a pretty close approximation of the suite of server tools running on Leland.

  1. Download and install MAMP (the basic, not the Pro version) from http://mamp.info. (These instructions are based on version 1.7.1.)
  2. Launch MAMP to get the Apache and MySQL servers running
  3. Go to http://localhost:8888/MAMP
  • Go to the phpMyAdmin area
  • Under Create new database, create an empty database with the same name as your Drupal database (g_groupname_drupal), collation utf8_unicode_ci
  • Back at the phpMyAdmin home page, click Privileges, then click Add a new User.
    • User name: Use text field: databaseusername
    • Host: Local: localhost
    • Password: Use text field: databasepassword
    • Global privileges: Check All
    • Click Go at the bottom right of the screen
  • Change the PHP memory limit for MAMP
    • Open /Applications/MAMP/conf/php5/php.ini with a text editor
    • Find the line that says
      memory_limit = 8M      ; Maximum amount of memory a script may consume (8MB)
    • Change it to
      memory_limit = 64M      ; Maximum amount of memory a script may consume (20MB)
    • You may have to increase it further than that, but 64MB should be OK
    • Save php.ini then restart the Apache server for the memory increase to take effect
  • Step 2: Copy the Drupal Files and Database

    1. Copy the drupal folder from afs/ir/group/groupname/cgi-bin/ to /Applications/MAMP/htdocs (on your local machine)
    2. Copy the .htacess file from a base Drupal install and place in /Applications/MAMP/htdocs/drupal
    3. Copy and un-gzip g_groupname_drupal database from afs/ir/group/groupname/db_private/g_groupname_drupal.sql.0.gz (0 is the most recent backup; you can unzip this to your Desktop or Documents folder - any temporary place where you'll remember it later)
    4. Open /Applications/MAMP/htdocs/drupal/sites/default/settings.php in a text editor and change the following lines:
      • Line 93:
        $db_url = 'mysql://ggroupnamedrupa:password@localhost:8889/g_groupname_drupal';
        • (You will most likely just be replacing mysql-user.stanford.edu with localhost:8889)
      • Line 115:
        $base_url = 'https://www.stanford.edu/group/groupname';  //NO trailing slash!
        • comment out the entire line by putting a # or // at the beginning

    Step 3: Import the Database Using MySQL Administrator

    1. Download and install MySQL Administrator (part of the MySQL GUI Tools). Launch it.
      • In MySQL Administrator:
        • Connection:
          • Server Hostname: localhost
          • Port: 8889
          • Username: drupaldatabaseusername (e.g., ggroupnamedrupa)
          • Password: drupaldatabasepassword
          • More options:
            • Connect Using Socket: /Applications/MAMP/tmp/mysql/mysql.sock
        • Click Connect
        • Restore tab
          • Click Choose File...
          • Select your unzipped database file (g_groupname_drupal.sql - you did remember where you unzipped it, right?)
          • Click Restore Backup
    2. In a browser, go to http://localhost:8888/drupal/
    3. Celebrate!

    Notes on Security

    The default install of MAMP installs MySQL with a username of 'root' and a password of 'root'. The article below details how to change the root password and edit your access settings to secure your MAMP installation. Regardless, MAMP is not intended to serve as a live web server. Be sure you have your firewall turned on before running MAMP.
    How to Secure MAMP/>

    Securing your MAMP installation

    1. Change MySQL root password (using phpMyAdmin (under Privileges) or MySQL Administrator)
    2. Change root password in /Applications/MAMP/bin/phpMyAdmin/config.inc.php, /Applications/MAMP/bin/mamp/index.php, /Applications/MAMP/bin/stopMysql.sh
    3. Create .htacess and .htpasswd files (using Dynamic Drive's online .htpasswd tool) and place them in /Applications/MAMP
    4. And it probably doesn't hurt to replace the favicon.ico in /Applications/MAMP/bin/