Setting Up a MultiSite Drupal Installation Using cPanel

Recently, I had a need to set up a multisite installation on a shared hosting environment (Hostmonster).  My only access to the server currently, until I jump through the appropriate hoops to get SSH access, is FTP and cPanel.  Try as I might, I had difficulties with the installation until I found this article here.  Unfortunately, there are just a few missing steps, so with credit to the original author, kham08 over at Drupal Groups, I am going to give a fuller explanation.  Finally, play careful attention to when you use site1 and site1.yourdomain.com.  It does matter.

  1. In CPanel, set up the subdomain and point it to http://yourdomain.com (The DNS updates from the subdomain add/redirect can take several hours to complete.......). For the example of site1.yourdomain.com, a folder named 'site1' will be automatically created by CPanel. Delete the folder that was created. (NOTE: many cPanels will display the document root as /public_html/site1.  There is no reason to create a redirect).
  2. Create a folder in the sites/ folder that matches the subdomain you want to create (so for site1.yourdomain.com, the folder name would be site1.yourdomain.com).
  3. Create directory /sites/site1.yourdomain.com/files/ with permission 777.
  4. Duplicate the settings.php file from the default folder and place it in your newly created folder from step 2.
  5. Edit the settings.php file you just placed in the site1.yourdomain.com folder so that it does not point to a database. You can replace the line that has your other site's database information with this: 

$db_url = 'mysql://username:password@localhost/databasename'; 

You will also need to edit the line that assigns the base url with this:

$base_url = 'http://site1.yourdomain.com';  // NO trailing slash!

 

6.  Then give settings.php permissions of 777 (Drupal will reset permissions to 644 when it is finished with the file). This will allow step 10 below to load your database tables.

7.  Use the following example to create a 'multisite.php' file and upload via FTP or CPanel's File Manager. Make sure you change the path to whatever the path to your web root is.

 
<?php
  symlink( '/home/username/public_html/',

'site1' );
?>

 

8.  Create a database and database user for site1.yourdomain.com.  Depending on your hosting provider this can be done in phpMyAdmin or a separate icon under Databases in the cPanel.  Hostmonster does this under an icon labeled MySQL Databases.  Keep track of of the database name and database user and database password.  Also don't forget to grant all permissions for the database to this database user.

10.  Go to your subdomain and start the Drupal 6 installation process. Drupal will ask for your database information and then install the tables necessary to run the new site.

11.  You're all set to use the new site.

Comments

Just what I've been looking for

This post is just what I've been looking for, but after performing all the steps, the install script still isn't loading... I want a Drupal subdomain site for developing and testing while my other site (non-Drupal) still displays at the main domain. In public_html I have two folders: one for the non-Drupal main site and one for my developing Drupal site. Does the symlink php file go in the same directory as the setting.php file, or does it go in the public_html folder? I'm not sure what I'm doing wrong. I hope you get this message, but if not, thanks for the informative post anyway.

multisite.php

You don't say where to put this file and what to do with it.

Placement of File

The file used for creating the symlink is placed in your public_html folder or whatever folder your host calls it.  Basically you want to be able to go to http://yoursitename.com/symlinkfile and have it execute.  Hope that helps.

Query

Thanx for your tutorial. Following your tutorial, I am able to do what you have said. Now, what if I want to run multiple sites, with different domain names with 1 installation. I dont want the second site in a subdomain, but I want it on some other domeian (say by domain parking). How to do this? Can you please help me? Katte.