Notes on Multi-sites with Separate Code bases
A simple Multi-Site install uses different databases for each site that the installation is hosting. In a nutshell, a simple Multi-Site extends a "Singular-Site" installation by the web developer (that's you) adding folders for each site that is served by the installation, in the "sites" directory.
The "default" Folder
When you install a fresh copy of Drupal, a "default" folder is created inside "theRootOfYourInstallation/sites". Inside this folder resides a file called "settings.php" which contains this line of code:$db_url = 'mysql://username:password@pathTodataBase'; to securely access your database.
During the initial database installation wizard, Drupal populates that particular line of code with values you entered into the fields.
The reason this is called "default" is because, well, this is the default folder that Drupal looks into to find (in the "settings.php" file) they keys to access the databases. The "default" folder can also contain other items, such as a folder called "files" that contains the files for the default installation.
The Key to Understanding Multi-Sites
For continuity, I will use "example.com" as the domain name for the "default" installation / folder and "doesthiswork.com" as the domain name for the site we are adding to this installation.
Now that you know about the "default" folder, you can begin to understand how to add multiple sites to one installation: to add another site to this installation,
- Create a sibling of the "default" folder with the domain name of "doesthiswork.com" . It is way important to use the extenstion (the .com or .edu, or .org).
- Inside this folder, you will include a fresh version of "settings.php" (renamed from a "default.settings.php" taken from the zipped files of fresh Drupal core files)
- Make sure that you have a fresh database created with no tables in it. Write down the path to the database, the username and password
- Now you are ready to point your site to the root of the installation. The tricky part of this "simple" instruction is find where your DNS provider lets you point to another site. An example of a solution to this step is this: Say my "default" domain name (that goes to the default folder) is http://www.example.com and a domain /site that I want to add to this installation is http://www.doesthiswork.com. In the DNS panel for http://www.doesthiswork.com, I would point the CNAME to http://www.example.com. When Drupal gets a request for "doesthiswork.com", it will find the doesthiswork.com folder in sites.
- The first time you go to "doesthiswork.com", you will be greeted with the welcoming Drupal Installation Wizard". Once you finish the installation wizard, the keys to your database kingdom will be saved an you will be free to enter your new Drupal site.
So, what's the key to understanding how this works? It is: for every site that you add on this installation, you will need to create a separate domain name folder in sites with (at least) a "settings.php" file. Each folder/settings.php file points to a different database installation. Drupal uses the files stored on the multisite server, in addition to the data in each database to serve up the site.
For each new site that you add, you will have to run through the installation wizard, setting up the site and adding content. (See installation profiles to make your life easier!) To reiterate: when you update a module, you will have to run "http://www.example.com/update.php" and "http://www.doesthiswork.com/update.php" (and other update.php's for each site on your multi-site install) to update EACH database. You might think that this is still alot of work... but it really is a time saver.
Remember to:
- put your sites in maintainence mode (admin/settings/site-maintenance)before
- run cron manually (admin/reports/status/run-cron)
- and clear the cache (admin/settings/performance)
after you run update.php !
Additional Files to place inside your "default" sibling
You can also have
- Files
- Theme
- Modules
as folders in the "doesthiswork.com" folders. Those items will only be seen by the "doesthiswork.com" installation. As you might have guessed, items in the "theRootOfYourInstallation/sites/all" folder will be avaliable to ALL the site in your Multi-site install.
If you place all your modules in the "theRootOfYourInstallation/sites/all" folder, when you upgrade to an newer version, you only have to replace the module there. However, you need to "update.php" on all sites in your multi-site... including your default site.
One of the things that can trip you up is forgetting to create a "files" folder in your "doesthiswork.com" folder. Make sure you have done that to keep separate files from "different" sites.

some modest (perhaps lame) suggestions
This article's title, "Notes on Multi-sites with Separate Code bases" - would perhaps read better as, "Notes on Multi-sites Using the Same Code Base"
We also read:
"Remember to:
. put your sites in maintainence mode (admin/settings/site-maintenance)before
. run cron manually (admin/reports/status/run-cron)
. and clear the cache (admin/settings/performance)
after you run update.php !"
I always had the impression that we should put a site in "maintenance" mode BEFORE running update.php (it may also be better to perform the other two before as well).
Thanks.
Multi-sites without symlink and with no access to httpd.conf
If you are not able to modify the httpd.conf, but you want to have a multi-site installation, where one site in a subdirectory (example.com/foo) should be protected via http-auth, you have to do only some more work:
<?php chdir ('..');include './install.php';?><?php chdir ('..');include './update.php';?><?php chdir ('..');include './index.php';?>That's it! Maybe, you have to ajust the base_url in 'example.com/sites/example.com.foo/settings.php' to 'http://example.com/foo'.