Setting up a Drupal multi-site
If you’re hosting your site(s) using inexpensive shared hosting that uses cPanel as the interface for server configuration, you can use the steps below to set up a Drupal multi-site.
Here’s the big picture:
- When you create a subdomain or assign an add-on domain in cPanel, a directory is created in /home/[username]/public_html for that subdomain or add-on: /home/[username]/public_html/newdomain. There's probably some default .html files in that directory.
- When you go to newdomain.com, the server looks in that /home/[hosting account username]/public_html/newdomain directory for what it should display.
- You need to remove that directory and create a symlink (like a fake directory that redirects to a real directory somewhere else) in its place that points to the main Drupal install (i.e. the one you’ve already set up for your first site).
- In your Drupal sitesfolder, create a directory for your new domain. I generally use its full name: e.g. mysecondproject.org.
- Now when you go to mysecondproject.org, the server looks for the folder it created for the new site, the symlink redirects it to the to the main Drupal directory you set up for your first site, then the sites/sites.php file directs it to the folder that corresponds to your second project’s files.
Now for the specific steps for how to make this work. This assumes that your main Drupal install is directly in the public_html directory (i.e. when you open the public_html directory, you see folders like "sites", "modules", "profiles" and files like "install.php" and "index.php"). If your main Drupal install is in another directory, modify the directions accordingly— for instance, where it says "public_html/sites", instead go to "public_html/[your-drupal-directory-name]/sites":
- Create a database for the second site, the same way you did for your main Drupal install. Create a user (or use the same user you assigned to your main Drupal install) who has full permissions to the database.
- If you're using a new domain name for your second site (e.g. myseocndproject.org): log into cPanel, go into Domain Manager and add a domain as an addon (NOT parked). This will create a directory in public_html/mysecondproject.
- If you're creating a subdomain (e.g. mysecondproject.myfirstproject.org): in cPanel, go to Subdomains, add your subdomain, and for Document Root, create a directory directly in in public_html. (Do NOT try to circumvent the symlink step by creating the document root for your subdomain in sites/subdomain.olddomain.com. It won't work. I tried it.)
- FTP to your site (or SSH, if you prefer and your hosting company permits it) and create in public_html/sites a new directory with the full name of your new site: mysecondproject.org.
- Make a copy of the settings.php file for your main Drupal install (it should be in public_html/sites/default) and modify the things in bold, in order to put in the new database, username and password. If there are other differences between the configuration in your file and this example below, use the settings in your file:
$databases = array (
'default' => array (
'database' => ’name_of_your_database',
'username' => ‘username_with_access_to_database',
'password' => ‘password_for_database',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
If your new database has the same user as your original Drupal database, the only thing you have to change is the at the end of the line. (Note: your hosting company might require something other than "localhost" there. Whatever is in the settings.php for your original Drupal site, don't change it for the second site.)
- Upload the modified settings.php to the directory for your new site (public_html/sites/mysecondproject.org). Also create a directory in public_html/sites/mysecondproject.org named files.
- Delete the directory in public_html that was created when you added the new domain or subdomain
- SSH into your site, and type this (filling in the correct information, of course):
ln -s /home/[hosting account username]/public_html/ /home/[hosting account username]/public_html/[subdomain]. Here, [subdomain] is the name of the directory you deleted in the previous step.
- If your hosting company won't allow you SSH access: you can accomplish the previous step by uploading a specially configured text file; see here for instructions.
- If everything has worked, you can now go to mysecondproject.org/install.php (don't forget the "install.php" part, or you'll just get a lot of error messages) and go through the installation for your second Drupal site.