Multisite setup using a single Drupal instance
Note
The downside of the following technique is that no two host can share the same IP and different SSL certificates for secure login. This opens up vulnerabilities to your drupal installation.
Multi-site/Single Instance
This article is intended for administrators who want to set up multiple sites (perhaps for multiple clients) running on a single Drupal installation. The goal is to keep everyone's site separate (different themes, content, enabled modules etc...) while sharing a single Drupal codebase.
I won't go into full details on how to install Drupal in a shared hosting environment, there are several other articles you can reference on that topic, although knowing the following is helpful:
- You will need to setup a new MySql database noting its name. That database should be assigned a user who has full privileges. Make sure you have the username/password for the DB user handy.
- Under the root/sites/default directory is a file called default.settings.php. This file must be re-named to settings.php and placed on the server and made writable.
- Certain PHP functions may need to be turned on or off (When running the install script the first time it should provide this information) Since many shared hosts run CPanel you should be able to take advantage of php.ini Quick Config a nice non threatening web interface that is easier to modify compared to adding a php.ini file with custom overrides or doing the same with your .htaccess file.
- Although not required, I would recommend that your Drupal implimentation be installed on your primary domain so that it is placed in the html root (i.e. /public_html/). I'll explain how this can make your life easier in a bit.
We will assume that you have successfully installed and tested your Drupal installation. Lets assume it is named www.myDupalSite.com. Now it's time to create another site by following these steps:
- Make sure that www.mysecondsite.com is parked on your server. By default (at least in CPanel) it will point to your root html directory which is exactly what we want.
Assuming the parked domain has propagated typing in www.mysecondsite.com at this point should show you your drupal implimentation at www.myDupalSite.com - Create a new MySQL database to house the second sites content and information.
- Assign a database user (with full permissions) creating this account if necessary. You may use the same master user account for all Drupal databases if desired.
- Create a directory for root/sites/mysecondsite.com
- Copy the settings.php file in your root/sites/default directory to your root/sites/mysecondsite.com directory. Make sure it has the appropriate file permissions
- Open the file and modify the database (and database user) settings to point to your second web sites database
- Now you can go to http://www.mysecondsite.com/update.php and run through the implimentation to populate your new Drupal site database.
Congratulations you should now have 2 separate websites capable of using different themes and with different content running on a single Drupal instance.
Some good things to be aware of regarding multi-site implementations:
- If it is appropriate for all modules and themes to be shared with all sites then you can disable update checking on all but your primary Drupal implimentation (which should have all modules enabled). In instances where some sites may have exclusive access to themes and/or modules you don't wish to make generally available you may need to enable update checking for those sites.
- Themes that you wish to be made available to all sites should be placed in /sites/all/themes/theme_name/. A Theme that should be made available to a specific sites (i.e. mysecondsite.com) should be placed in root/sites/mysecondsite.com/themes/theme_name/
- Availability of modules is similar to themes. Utilize root/sites/all/modules when you want a module to be available to all Drupal instances (each instance can choose to enable or disable the module).
- Although you are running a single instance of Drupal you have multiple databases that may need to be updated when a new version comes out. Please make sure to disable your sites and run the update.php file once for each site before re-enabling sites when finished.
