Saturday, May 25 2013
How to setup Drupal Multi-site: Run multiple sites from the same code base
This tutorial is meant to get you up and running with a Drupal multi-site installation quickly and painlessly. I remember trying to figure this out for many weeks. Turns out it's not difficult. It's just difficult to explain.
Here's how it's done from start to finish in the simplest of explanations:
Let's start with Hosting: I highly recommend Bluehost.com.
Bluehost costs $6.95/mo (charged on an annual basis), which is totally reasonable and they have this "Simple Script", one-click-Drupal-install that also has one-click-Drupal-core-updates. Sweet.
If you like this tutorial, kindly follow my Bluehost affiliate link to sign up for their service as a "thanks, Tim!". I get $65 without any negative impact to you.
Full disclosure: I'm an affiliate with lots of hosting companies. Bluehost is my favorite.
Now that you have hosting, let's install Drupal using Bluehost's 1-click Drupal install.
Go to your Bluehost cPanel. Scroll down and click on "Simple Scripts". On the next screen click on Drupal. Bam! Done. Drupal installed.
Next up: Multi-site
From the Bluehost cPanel, click on the "Domain Manager" tab. For the next part we have an question and answer:
Is your domain registered at Bluehost?
Click on the "Assign" link next to the domain you'd like to assign.
On the following screen, make sure to select "Parked domain"
Is your domain registered somewhere besides Bluehost?
Then change the nameservers to ns1.bluehost.com and ns2.bluehost.com like this:
Now let's install a database for the second website (the Bluehost "Simple Script" already installed a DB for the first site)
Revisit your Bluehost cPanel and select "MySQL® Databases":
On the subsequent screen enter a unique name for your database (use the name of your second domain, most likely) and click "Create database":
Once you've done that, go back to the page where you created the new database, scroll a bit further down that page, and add a new user for that database (I'd probably name it something similar to the domain name here as well):
Finally, add that user to the database.
Give that user full privileges:
Now for the fun stuff! ;)
- Create a new subdirectory of the 'sites' directory with the name of your new site (see below for information on how to name the subdirectory).
- Copy the file
sites/default/default.settings.phpinto the subdirectory you created in the previous step. Rename the new file to
- Adjust the permissions of the new site directory, and grant write permissions on the configuration file
- Make symbolic links if you are using a subdirectory such as example.com/subdir and not a subdomain such as subd.example.com (see the subdirectory multi-site section below for details).
- In a Web browser, navigate to the URL of the new site and continue with the standard Drupal installation procedure.