2007-05-30

5 Steps to implement multisite in Drupal

There are already many use cases for multisite with one installation Drupal. The handbook of Drupal has some useful tips too. see: Multi-site installation and set-up

Here is just another typical one:

The customer needs two kinds of presentations of the same content, and such presentations should be decided by different URL.

More concretely, assumed that we have a domain named "http://www.example.com". This is the main site used for some people. At the same time, "http://www.example.com/show/" will be used for some other purpose, e.g. as a content provider with different front page.

Let's do it step by step:
  1. Find the configuration file httpd.conf of your Apache server. Add the following line at the end of the file.
    Alias /show "C:/Programme/xampp/htdocs/drupal/" #<- The path to your drupal directory. It can be "/var/www/htdocs/" on a linux server or alike.
    It maps the path to your drupal installation directory.

  2. Go to the /sites directory under the drupal installation directory. Copy the /default directory to a new directory with all the containing files. The new directory can be called "/www.example.com.show" or "/localhost.show". It depends on where you install your drupal.

  3. Make changes to the settings.php in the new directory.

    1. Since we use the same database and don't want to create new tables, we use:
      $db_url = 'mysql://name:password@localhost/drupal';
      $db_prefix = '';
    2. For the URL we use, change the base URL:
      $base_url = 'http://localhost/show'; // NO trailing slash!
    3. Something we want to change is the theme and front page, etc. It can be achieved by:
      $conf = array(
      'site_name' => 'My Drupal site',
      'theme_default' => 'pushbutton',
      'anonymous' => 'Visitor',
      );
  4. To get clean URL's with multi-site I added the following to the .htaccess file
    # rewrite commands for drupal dev sites
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} ^/show/.*
    RewriteRule ^(.*)$ /show/index.php?q=$1 [L,QSA]

  5. restart the Apache server and go to the URL "http://www.example.com/show/" to see what happens.
There are some bugs on using another theme with the different URL. For example, the blocks in the Drupal will be not shown correctly. The only solution currently is copying the main theme to a new directory with a new name like "showme".This makes a new theme with different name in Drupal, then edit it to fit your requirements.

1 comment:

Anonymous said...

Good brief and this post helped me alot in my college assignement. Gratefulness you as your information.