So you've got one Drupal site up and running-- but what if you want two? I've been struggling to set up a Drupal multisite install (same code, different databases) off and on for a few weeks now, but never really understood what's going on behind the scenes of a multisite, which left me blindly trying every tutorial I could find and getting increasingly confused and frustrated. The technical details here are still a black box to me, but here's a conceptual outline that made everything click for me. The assumption here is that you're using shared hosting with cPanel, and you have working Drupal 6 installed in your public_html directory, so a few details may be different if you have a different setup.
- When you create a subdomain or assign an add-on domain in cPanel, a directory is created in /home/[username]/public_html for that subdomain or add-on: /home/[username]/public_html/newdomain. There's probably some default .html files in that directory.
- When you go to newdomain.com, the server looks in that /home/[hosting account username]/public_html/newdomain directory.
- You need to remove that directory and create a symlink (sort of like a fake directory that redirects to a real directory somewhere else) in its place that points to the main Drupal install.
- In Drupal's sitesfolder, create a directory for your new domain-- with its full name: newdomain.com, newdomain.olddomain.com, whatever it is.
- Now when you go to newdomain.com, the server looks first to the main Drupal directory (/home[username]/public_html), then some kind of Drupally magic (as far as I'm concerned) directs it to the directory in the sites folder that matches the domain name you typed.
Now for the specific details on how to make this work. (The Drupal discussion thread I used to get my installation off the ground is helpful but dates back to Drupal 4.x.)
- Create a database for the second domain, the same way you did for your main Drupal install. Create a user (or use the same user you assigned to your main Drupal install) who has full permissions to the database.
- If you're using a new domain name for your second site: go into Domain Manager and add a domain as an addon (NOT parked). This will create a directory in public_html/newdomain.
- If you're creating a subdomain: in cPanel, go to Subdomains, add your subdomain, and for Document Root, create a directory directly in in public_html. (Do NOT try to circumvent the symlink step by creating the document root for your subdomain in sites/subdomain.olddomain.com. It won't work. I tried it.)
- FTP to your site (or SSH, if you prefer and your hosting company permits it) and create in public_html/sites a new directory with the full name of your new site: newdomain.com, newdomain.olddomain.com.
- Make a copy of the settings.php file for your main Drupal install (it should be in public_html/sites/default) and modify this line:
$db_url = 'mysql://[DB username]:[DB user password]@localhost/[new DB name]';. If your new database has the same user as your original Drupal database, the only thing you have to change is the [new DB name] at the end of the line. (Note: your hosting company might require something other than "localhost" there. Whatever is in the settings.php for your original Drupal site, don't change it for the second site.)
- Upload the modified settings.php to the directory for your new site (public_html/sites/newdomain.com). Also create a directory in public_html/sites/newdomain.com named files.
- Delete the directory in public_html that was created when you added the new domain or subdomain
- SSH into your site, and type this (filling in the correct information, of course):
ln -s /home/[hosting account username]/public_html/ /home/[hosting account username]/public_html/[subdomain]. Here, [subdomain] is the name of the directory you deleted in the previous step.
- If your hosting company won't allow you SSH access: you can accomplish the previous step by uploading a specially configured text file; see here for instructions.
- If everything has worked, you can now go to newdomain.com/install.php (don't forget the "install.php" part, or you'll just get a lot of error messages) and go through the installation for your second Drupal site.