The guidance provided below assumes:
- You have read "Multiple Sites, Multiple Databases, One Installation of Drupal" located on this site.
- You have read and followed the instructions in "Two Sites, One Database, One Installation of Drupal: DB Setup" located on this site.
- You are working with Drupal 4.6.x.
- You are only sharing two sites.
- The primary site is already configured.
- You have a second domain directed to your Drupal home directory.
The processes that differ are the database setup and the settings.php configuration. This article focuses on the settings.php setup. There are several steps required in order to setup the settings.php file starting with its location, its creation, and its editing. There are four parts of the settings.php file that needs to be edited: database name, database prefix array, base url, and the variable overrides.
Step 1: Create your Drupal site directory
The first step is to create a directory for your secondary site. In Drupal, go to the sites directory. If you haven't changed the name of the default directory contained with the sites directory, change that directory to be the domain name of your primary site. For example, myprimarysitename.org.
Then create a new directory with the same permissions as the default directory. Name that directory using the domain name of your second site. For example, mysecondsitename.org. If you are using a temporary domain name, name the directory the temporary domain name. You will change it later when you are ready to go live with your preferred domain name.
Step 2: Upload the settings.php file
Now that you have an empty directory for your second site, you need to create the settings.php file. This can be done several ways. One way is to upload a version of the settings.php file into this directory. The version you choose can be a copy of the primary site settings.php file or it can be the default you got with Drupal.
In either case, the permissions associated with the settings.php file need to be the same as those assigned to the primary site settings.php file.
Step 3: Setup the database name
This is the same step taken when setting up the primary site settings.php file. This command should be exactly the same. If you did not configure the settings.php file, view the contents of the version located in your sites/default directory. Locate and copy the command line that looks like this but has your specific information versus this generic data. You should see your command line just beneath this one:
$db_url = 'pgsql://username:password@localhost/database';
Step 4: Setup the database prefix array
There are several suggestions on the drupal site as to how the prefix array should be configured. The following is designed to accomplish the task described here AND work in Drupal 4.6.x.
Beneath the database url command line, you need to insert these two command lines:
$db_prefix = array(
'default' => 'secondsitename_',
Then you need to list all the tables your two sites will share, using the syntax shown here:
'access' => '',
'accesslog' => '',
To ensure all works correctly, all the tables need to be listed. A typical installation of Drupal 4.6.x will have about 50 tables. At the end of the list, be sure to include the );
If you add tables as the result of adding a new module, you need to add the new table name to this list if you want the module function to work on each site.
Step 5: Setup the base url
This is the same step taken when setting up the primary site settings.php file. If you are not familiar with this command line, you are looking for a line like this:
$base_url = 'http://domainname.com';
This is the domain name you used for the directory. It is the one you want to use while setting up your second site. Remember that this might be a temporary domain name. Recall, if your already existing second site domain name is mybestsite.com, maybe you buy a one year subscription to mybestsite.net, or the like.
Then one you are ready to go live with your preferred second site domain name, you will eidt this command line accordingly.
Step 6: Setup the primary variable overrides
The last part of the of the settings.php file you need to edit is the section called "Variable overrides." In this section you will use the command line:
$conf = array(
And you will follow this command line with the variables that you wish to override. For example, at a minimum you will want to use these two lines:
'theme_default' => 'friendselectric',
'site_name' => The name of my second site typed here',
These two variable will provide a unique theme, one different than the primary site, and a unique name for the theme to use. This is the bare minimum needed to make the same content look different.
Optional step: Setup other variable overrides
There are other variables that you can override as well. If you want a list of variables that used in Drupal, access the database table called variables. Not all variables are easy to override.
To accommodate a unique front page, you can create a unique mission by adding this command line:
'site_mission' => 'type here the text and html code you want to use for your mission.',
A unique mission statement will allow your front pages to be different to an extent, allowing each site to show the same nodes promoted to the homepage.
If you want the second site to simply have its own front page and not show the promoted notes of the primary site, you can override the "site_frontpage' variable like this:
'site_frontpage' => 'node/1',
The node/# you use corresponds to the content node you created to be the "homepage."
Of course, both sites can have their own frontpage thus eliminating the ability to promote content nodes to the front page. For the primary site, you would edit the admin/settings/ feature and assign a node to the "default front page" field on the settings page.