I'm about to set up a multi-site configuration on Drupal 6. I (mostly) understand how to do that; among other things, there will be directories under /sites called, for instance, /sites/example1.com, /sites/example2.com. The catch is that I want to host these sites on both a development server and a production server, but have both dev and prod servers working from the same code base. (The development and production servers will be physically separate machines, if that matters.)
On a single-site configuration, this is easy: the site lives inside /sites/default, and the web servers and Drupal make all the connections appropriately, regardless of what the domain name is on the server. (I have to tweak the settings file to point to the right database, but that can be handled.) But in the multi-site case, how do I get around having four directories under /sites, like /sites/example1.com, /sites/dev.example1.com, /sites/example2.com, and /sites/dev.example2.com, and then manually making sure that the changes I make in /sites/dev.example1.com get copied into /sites/example1.com? Is there any hope here? Thanks!
Comments
Answered my own question, I think
For the record: I think I have this working; here's how:
* Configure the production server as www.example1.com.
* Configure the development server as dev.example1.com (key point: the second-level domain must be the same as the production server, but the third-level domain must be different)
* Put the Drupal site configuration stuff into /sites/example1.com
* Upload the single set of files to both servers.
The trick here is the "stripping" method used in the handling of the settings directory. When a request comes to the development server for "dev.example1.com", Drupal will look for the folder /sites/dev.example1.com. When it fails, it will strip off the TLD and look for /sites/example1.com, which will succeed. The same thing will happen on the production server, except that the initial search will be for /sites/www.example1.com.
So far, so good, anyway....
I wouldn't have thought of
I wouldn't have thought of that, ok if it is working. I've used sym links to achieve this.
So
The command for a sym link in Linux would be
redpuma's method is preferred
redpuma's method is preferred for a number of reasons, the biggest one being you only have to maintain a single set of files. Another suggestion is to use a semantically meaningful directory (say sites/example or sites/ExampleOfADrupalSiteForSakeOfArgument ) then symlink /sites/www.example.com, example.com, dev.example.com and whatever other hostnames you might need. Thing is, though, you really should figure this out and do it FIRST, because once you've started work on a site, the paths start to propagate around the database making migration something of a pain. The good thing about using a sort of hostname neutral approach, though, is that if you need to migrate your environment to a system to which you CANNOT match the hostname -- say, for example, you start using the Acquia Dev Desktop stack -- you can still use the same codebase because all you need to do is symlink (mklink or junction on a windows machine depending on what windows version you have) the localhost (or whatever) directory you're able to use to the sites/example directory and you're golden.
You could also use this trick to allow your single site to operate on multiple hostnames, but there are probably much better and considerably more efficient ways to do that (using .htaccess for example).