Moving a Drupal multisite install to localhost (OS X and MAMP)

Multisite

Moving a Drupal website from one hosting provider to another is not an easy task. Moving a multisite website to a localhost has some added layers of complexity. That's the reason for this short tutorial with a description of the process. Environment: OS X Mavericks and MAMP.

Log into the website and install the Backup and Migrate module. Download your database to a location on your hard disk. Backup and Migrate works much better than a manual export of the database.

Connect to your website via FTP. Copy all the files to your hard disk, except the /sites folder. From the sites folder you only move the folders /all en /mywebsite.com.

Keep settings.php, which you can find at /sites/mywebsite.com, as much as possible in it's initial state. This means you have to look into settings.php and create that user in phpmyamdin (of course with the needed permissions).

Go to httpd.conf under /Applications/MAMP/conf/apache and look for 'Virtual Hosts'. Make sure the Virtual Hosts are accessible for the multisite config at the localhost by uncommenting an include:

# Virtual hosts
    Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
  

Go to the vhosts file at /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf and change the port of the NameVirtualHost from 80 to 8888. You can check the Preferences of MAMP to be sure of the exact port.

NameVirtualHost *:8888

Add the vhost local.mywebsite.com to the same httpd-vhosts.conf Apache file. Hereunder an example of a configuration for the standard MAMP-port 8888 (note: the ErrorLog and CustomLog rules aren't that important):

<VirtualHost *:8888>
  ServerAdmin webmaster@local.mywebsite.com
  DocumentRoot "/Applications/MAMP/htdocs/mywebsite"
  ServerName local.mywebsite.com
  ErrorLog "logs/local.mywebsite.com-error_log"
  CustomLog "logs/local.mywebsite.com-access_log" common
</VirtualHost>

Beware! For these configurations it is important we als add the normal localhost to httpd-vhosts.conf. This one has to be linked to the root, or htdocs. This looks like this:

<VirtualHost *:8888>
  DocumentRoot "/Applications/MAMP/htdocs"
  ServerName localhost
</VirtualHost> 

Change the hosts file of the operating system. When using Mac OS X this can be found at /private/etc/hosts. Add following code to the file (and save the file):

127.0.0.1 local.mywebsite.com

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.