Emulating a Drupal multisite installation in your local dev environment

Before I get started I'd like to thank deekayen for turning me on to this.

For the purposes of this post let's assume you're developing for a project that's using Drupal's multisite feature to manage 3 websites:

Alias your way to victory

Instead of dealing with a bunch of virtual host configuration and the potential attendant problems that go with that we can take the easy way out courtesy of hosts file aliases:

Adding an alias for 127.0.0.1 to /etc/hosts for each site in our multisite installation gets us halfway there.

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1     localhost site1 site2 site3
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

To complete the picture, we create a symlink for each site in our Drupal sites folder.

cd /path/to/Drupal/sites
ln -s site1.example.com site1

Restart apache and now you should be able to view your local copy of site1 by pointing your browser to http://site1/

Freeman on web stuff

If it's wrong, bad or
stupid, let me just say that
I am not surprised.

- author unknown

User login

Navigation

More Drupal hotness

Powered by Drupal, an open source content management system