Same codebase, completely different content and users
This document assumes the following:
- You want to create more than one Drupal site using the same codebase (the same basic set of Drupal files, uploaded into one location).
- You know how to install mysql tables in your database.
- You know how to set up subdomains/folders/other domains that you want to use.
- You have already downloaded Drupal 4.7, and set up one MAIN site.
This document contains instructions on how to create completely separate Drupal
site, with different configurations, users and content. Nothing is shared between
the installations except the codebase.
Some definitions:
codebase: the basic set of Drupal files, included in the .tar.gz
file. the stuff that makes Drupal work.
database: a collection of tables that stores data.
Affected files:
settings.php (sites/default/...)
database.mysql
For this example, we will assume the following:
www.example.com: the MAIN site, where the codebase has already been uploaded,
and settings.php has been properly configured.
sub1.example.com; www.example.com/sub2; www.subexample.com : the other sites
we will create.
1. Create the following folders in your sites directory:
sites/sub1.example.com/
sites/www.example.com.sub2/
sites/www.sub3example.com/
Copy the settings.php file from sites/default into each of the above folders.
2. There are different database files (inside the database folder). Select
the one that is appropriate for your database version. Copy it to each of the
folders you made in step 1. This is OPTIONAL, but it will help you keep things
straight.
3. Decide on SEPARATE PREFIXES for each site. Below is what we will use for
the example:
site
database prefix
sub1.example.com
sub1_
www.example.com,sub2
sub2_
www.sub3example.com
sub3_
4. Configure your settings.php for each site.
This code MUST BE CHANGED FOR EACH SITE:
$db_url = 'mysql://username:password@localhost/databasename';Note; if you are using the same database as the MAIN site, the $db_url is the
same.
OPTIONAL:
# $base_url = 'http://www.example.com'; // NO trailing slash!
# $conf = array(
# 'site_name' => 'My Drupal site',
# 'theme_default' => 'pushbutton',
# 'anonymous' => 'Visitor'
# );
For sub1.example.com, the settings would be:
$db_prefix = 'sub1_';
$base_url = 'http://sub1.example.com';
$conf = array(
'site_name' => 'My SUB1 Drupal Site',
'theme_default' => 'pushbutton',
'anonymous' => 'Visitor'
);For www.example.com/sub2, the settings would be:
$db_prefix = 'sub2_';
$base_url = 'http://www.example.com/sub2';
$conf = array(
'site_name' => 'My SUB2 Drupal Site',
'theme_default' => 'fancy',
'anonymous' => 'Anonymous'
);For www.sub3example.com, the settings would be:
$db_prefix = 'sub3_';
$base_url = 'http://www.sub3example.com';
$conf = array(
'site_name' => 'My SUB3 Drupal Site',
'theme_default' => 'marvin',
'anonymous' => 'Guests'
);6. Upload the modified settings.php files in their respective folders.
7. Open the database file you copied into each sites folder. Find the following (don't forget the SPACE at the end!!!):
CREATE TABLE
INSERT INTO
Replace each 'create table' and 'insert into' with 'create table dbprefix_' and 'insert into dbprefix_'
For sub1.example.com:
CREATE TABLE >> CREATE TABLE sub1_
INSERT INTO >> INSERT INTO sub1_
8. Upload the modified mysql files into the database you specified in your settings.php.
9. Voila!
