How to handle a multisite installation with Mamp (using symlinks and virtual servers)

Every once in a while you run into a problem that forces you to either dig in and learn more than you really had the intention of learning, or return the client’s down payment. I ran into such a situation recently with an odd Drupal multisite installation.

Drupal handles multisite installs by routing to the folder in the sites directory which has the name of the site in question. So would run off of the settings.php file located in sites/

This is easy to deal with when working on a remote server, where you can use cpanel or some other point and click server administration interface to create subdomains, but how does one go about setting up a local development environment without changing the folder structure?

If you have Mamp pro you can create virtual servers through the Mamp interface, and you can set any virtual server to resolve locally, regardless of the url. So for the site you could technically get a local version running by creating a virtual server entitled and routing it to the Drupal installation in question. However this creates a problem… Now you can’t visit the remote version of the site without turning off the local virtual server. Not the end of the world, but it’s awkward.

Fortunately there is another alternative. Instead of creating a virtual server called create a virtual server with another name, any name you like. For now let’s say we use the name “localtester”, and route that virtual server to the Drupal directory.

There’s one last step to get this working. You need to trick Drupal into thinking that when it receives a request from localtester that it is actually receiving the request from Enter symlinks.

Using terminal we cd into the Drupal folder on our local computer and run the following command: ln -s localtester. What this does is make Drupal think that it is loading “sites/localtester” when it is actually running “sites/”, and that’s exactly what we want it to do!

Now if you type int localtester:8888 (or whatever the port number is set to on your server) then you will get the (as long as everything else is properly installed).

All of this is probably possible with a Wamp installation. I don’t really feel like setting up Wamp (or opening up a Windows computer) just to find out though.

Hope this was helpful.