Localhost and Drupal Multisites

By Erik , Thu, 11/11/2010 - 02:20
So I have set up my localhost with MAMP and I don't want to muck about with Dynamic DNS or constantly editing my /etc/hosts file to be able to bring down Drupal sites from multisite installations on our company servers. At work, we run a bunch of Drupal sites out of a single Drupal code-base (aka multisites). There are lots of domains, subdomains, etc. There's no problem at work for this, we've got it under control, but when I want to pull one of those sites down to my Macbook to do some playing, I have to do things a little differently. In general, to set up multisites, you create directories like sites/mysite.com or sites/inside.mysite.com, but without any DNS modification on localhost, to do multisites, I first symlink something to my drupal root This will allow us to launch Drupal from http://localhost/newsite, but will pull files and settings.php from the sites/default directory. Then to use a different directory from sites/default you create a multisite folder like sites/localhost.newsite where your site specific settings.php, modules, themes, libraries, etc. will go. Then my new site is available at http://localhost/newsite which is great for local development. But if I want to bring down a copy of http://inside.mysite.com for local testing, renaming the /sites/inside.mysite.com directory to sites/localhost.inside_mysite is a pain because the system table, files table, and probably a bunch of others are expecting sites/inside.mysite.com in a lot of filepaths. My savior is this core patch which enables you to tell Drupal: "I know you want to find a subsite directory called sites/localhost.inside_mysite since that's what the path on the URL is, but resist the urge and use sites/inside.mysite.com instead. Now, I access the site at http//localhost/inside_mysite but all of the settings and files are pulled from sites/inside.mysite.com. This way, if I make changes, I can bring them back up to the server without much hassle.

Comments