Drupal Development Environment on Mac OS X 10.6 - Multisite Capable

⚠️ Warning
This post is more than 10 years old. I do not delete posts, because even old information is still useful, but please know that some material on this page may be outdated or incorrect. Thanks!
Oct 28, 2009

I've begun working a lot more with Drupal multisites, as doing so saves a lot of time in certain situations (usually, when you have a large group of sites that use the same kinds of Drupal modules, but need to have separate databases and front-end information.

One problem I've finally overcome is the use of actual domain host names for development (i.e. typing in dev.example.com instead of localhost to get to a site). This is important when doing multisite work, as it lets you use Drupal's built-in multisite capabilities without having to hack your way around using the http://localhost/ url.

Here's what I did to use dev.example.com to access a dev.example.com multisite in a Drupal installation using MAMP (the dev.example.com folder is located within Drupal's /sites/ folder):

  1. Edit MAMP/Apache's httpd.conf file - it's located at /Applications/MAMP/conf/apache/httpd.conf
    1. Put in the following at the end of the file:
      <virtualhost>
        DocumentRoot /Applications/MAMP/htdocs
        ServerName dev.example.com
      </virtualhost>
  2. Restart Apache (in MAMP, click stop servers, then start servers).
  3. Open up Terminal (in Applications > Utilities), and type in $ sudo nano /private/etc/hosts
    1. Type in your password if requested
  4. In the hosts file, add a new line after the line that reads 127.0.0.1 localhost:
    • 127.0.0.1 dev.example.com
  5. Save the file by pressing Control+O (this writes the file) and then Return when it says 'File Name to Write:', then press Control+X to exit nano.
  6. Now, flush Mac OS X's DNS cache by typing:
    • sudo dscacheutil -flushcache

Now, if you are behind a proxy server (i.e. if you have the Network settings in System Preferences set to use a proxy server for Web traffic), you will need to also add your dev.example.com entry to the 'Bypass proxies for these domains' field (localhost/127.0.0.1 should already be present here).

Next time you visit http://dev.example.com/ in your web browser, Drupal should point you to the appropriate multisite folder on your local Mac!