Drupal Multi-site Configuration on a Dedicated Server

So I just figured out how to get Drupal's multi-site configuration working on my Rackspace Linux server.

Let's say your Drupal core is located at my-drupal-core.com. Install Drupal there, this will be your master copy.

Within your 'sites' folder, create a folder for each domain you will want to run off this core installation. Let's say we'll make a Drupal site, based on this core, which will be drupal-slave.com. So, within your sites folder, create a drupal-slave.com folder. I prefer using a different database for each site. So create the database for the slave site, and then copy the settings.php file from your sites/default folder, alter it for your slave database, and put it into the drupal-slave.com folder. While you're in there, create a files folder, you may need to change its permissions to 777.

So, your drupal-slave.com folder should look like this:

sites
   -- drupal-slave.com [folder]
      -- settings.php
      -- files [folder]
      -- modules [modules specific to this domain]
      -- themes [themes specific to this domain]

Now, on my server, every domain has a vhost.conf file, located inside a domains conf directory - this is at least how Red Hat does it. If you have a conf folder, but no vhost.conf file, go ahead and create it - you'll likely need to login as root to do this.

Now, within your vhost.conf file (for drupal-slave.com, in this scenario), you'll need to do something like this (alter for your own needs):

DocumentRoot /httpd/vhosts/my-drupal-core.com/httpdocs
<Directory /httpd/vhosts/my-drupal-core.com/httpdocs>
  php_admin_value open_basedir /tmp:/httpd/vhosts/my-drupal-core.com/httpdocs
  AllowOverride All
</Directory>

Then, (gracefully) restart Apache - viola! Works for me at least. By the way, the AllowOverride All is to allow the my-drupal-core.com's .htaccess file to work on all slave sites. The /tmp directory allows the slave site to write to the tmp directory for file uploads. Hope this helps someone.

Security

Note that with a multi-site setup, you really need to be careful of who can use the PHP filter (preferably, nobody). Reason being you can use PHP to read/output any domain's settings.php file and gain access to the database username and password for any domain sharing the Drupal installation, including the master domain. Careful! This alone makes me think I won't be using a multisite setup for high profile sites, or any site I'm not directly managing.

This entry was posted in Drupal. Bookmark the permalink.

10 Responses to "Drupal Multi-site Configuration on a Dedicated Server"

Leave a reply