Figuring out how to configure the multi-site feature in Drupal can be daunting. There is a lot of conflicting material on the net, perhaps due to the long life of drupal and different incarnations. The most recent documentation on the Drupal support site talks about editing the httpd.conf (Apache Hosts) file to handle multiple domains in Drupal. Unfortunately, most hosting companies don't let you access the httpd.conf file. Some charge for it, and some will make changes for you if you submit a support ticket. Laborious!
Fortunately it isn't nearly that complicated.
The following procedures for getting multiple domains to power off of a single Drupal install are tied to the Dreamhost hosting platform, but the techniques can be applied to any host with a little improvisation.
Once you have successfully installed Drupal on defaulturl.com, perform the following steps:
- If you haven't already, register domain2.com (this is the second domain that will be powered by the Drupal installation on defaulturl.com). Add domain2.com to your Dreamhost Web Panel under "Domains" < "Manage Domains". Very Important: Under Web Directory, by default Dreamhost will fill in /home/username/domain2.com/, this needs to read /home/username/defaulturl.com/ (Again, defaulturl.com here means the web address which you initially installed Drupal on). This points the domain at the Drupal installation and lets Drupal decide how to handle the user.
- Under Goodies, click "Manage MySQL": Create a new table for your Drupal data on domain2.com. For example, domain2_drupal for database name. Important: use the same hostname for domain2_drupal as you did for you initial Drupal install, i.e. probably something like mysql.defaulturl.com.
- Connect to your Dreamhost server via FTP. Go to the directory you installed Drupal in (probably your root directory, e.g. /defaulturl.com/) and then go to /sites/.
- You'll see two directories here: all and default.
- Create a directory call www.domain2.com where www.domain2.com is the name of your second domain. Be sure to include the 'www'.
- Copy the settings.php file from /sites/default/ into /sites/www.domain2.com/.
- Open the settings.php file and configure the following variables:
$db_url = 'mysql://username:password@hostname/databasename';
$base_url = 'http://www.domain2.com';
Username, password, hostname, and databasename can all be found on the Goodies > Manage MySQL page of the Dreamhost Web Panel.
- Point your web browser to: http://www.domain2.com/install.php. This will configure drupal to use the new MySQL table you've created. Select the install you'd like to perform and click Install.
- You're almost done, but first you'll need to copy the folder /sites/www.domain2.com/ and create a duplicate folder with the same settings file called /sites/domain2.com/. This will ensure that either way they type in the URL, they will be pointed to the correct page.
Finally, if your Drupal installation needs it, Dreamhost has an easy way to set up cron jobs. Go to the Dreamhost Web Panel > Goodies > Cron Jobs and click "Add New...". Insert the following information:
/usr/bin/lynx -source http://www.domain2.com/cron.php > /dev/null 2>&1
You can schedule it as frequently or infrequently as you like, and name it whatever makes sens for you. If you haven't already configured Cron on your default site, go through the same process substituting domain2.com for defaulturl.com.
And it's that simple folks.
Comments
This is great, bro.
This is great, bro.