Drupal multi-site with different databases in cPanel/WHM

In case you have a hosting with cPanel/WHM you can have multi-site with Drupal in three simple steps:

1. Create wildcard subdomain: if you don't have root access, which is very likely to happen, request your hosting to do the following:
# vim /usr/local/apache/conf/httpd.conf
Add this:
ServerAlias *.domain.com
Then:
# vim /var/named/domain.com.db
* 14400 IN A XXX.XXX.XXX.XXX
Replace XXX.XXX.XXX.XXX with the IP of the domain (e.g. 192.168.0.1).

Now restart two services:
# service named restart
# service httpd restart

The reason I do this is to save time creating a new installation under the same site. Without this step you would have needed to create a new subdomain then modify .htaccess file, etc...

Now when you visit: foo.domain.com, bar.domain.com, they will all be handled by domain.com.

2. Now create a new database, install Drupal to ~/public_html. This is going to be the default installation.

3. Whenever you need a new installation, say "foo", you will need to create a new db for it copy "sites/default" to "sites/foo.domain.com". Make sure you create "files", "modules", "themes" folders (if you need them) inside "sites/foo.domain.com", also make sure settings.php points to the new database created for the subdomain.

References:
http://rshagrawal.blogspot.com/2008/01/how-to-create-wildcard-subdomain-...
http://drupal.org/node/156720

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><p>
  • You may post PHP code. You should include <?php ?> tags.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options