Before installing

Last updated on
21 March 2018

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

Introduction

This module requires some advanced understanding of Drupal and of how DNS servers behave. If you simply untar the download and activate the module, it may not work correctly.

Domain Access works by reading the inbound HTTP_HOST request and serving content appropriate to the requested domain. For this to work properly, all domains for your site must be routed to the same Drupal installation on your webserver.

Domain Access was not designed to run on shared hosts, and you may need assistance from your provider to make it work correctly.

For more background on DNS and virtual host configuration, please try the following documentation:

For a general overview:

In-depth documentation with many examples for specific situations:

When you enable the module, it will create a {domain} table in your Drupal database.

On installation, all existing nodes on your site will be assigned to the default (primary) domain for your web site as well as to all subdomains. In order to change this behavior, see sections on setting DOMAIN_INSTALL_RULE and DOMAIN_SITE_GRANT below.

You will need to do the following before you install the module:

  • Read this document
  • Configure your web server DNS records appropriately
  • Install and configure Drupal normally

WARNING: The Domain Access module series instructs you to add a file include to your settings.php file. Do not add this command until after you have installed Drupal.

DNS and Server Configuration

For the module to work correctly, your web server must support Virtual Hosting (most servers do). Your new virtual host(s) must then be correctly configured on your server. In general, this involves small additions to the hosts file and the httpd.conf file.

In order for the Apache server to find your virtual host(s), it needs the ServerName (hostname & port the server uses to identify itself). If your server does not support Server Name Indication (SNI) then you will also require a secondary IP address configured on your server. In 2018, all major web servers and browsers have SNI support.

The two basic methods for doing this are to either:

  • Set up WildCard DNS, so that *.example.com resolves to your Drupal site(the asterisk indicates any and all names carrying the < example.com > suffix)
  • Set up each hostname specifically, so that one.example.com, two.example.com, (and so on) all resolve to the IP address(es) where your Drupal site is hosted.

For example, on a local testing machine, hostnames in my hosts file could be configured in the following way:

ken.test => 127.0.0.1
one.ken.test => 127.0.0.1
two.ken.test => 127.0.0.1
foo.test => 127.0.0.1

Mac OS users: this my hosts file is not findable through the Finder; to edit the /private/etc/hosts file use the terminal:

cd /private/etc; sudo nano hosts

(Taken from this excellent post: http://drupal.org/node/463262)

With their port and document root defined (WildCard set up) in the httpd.conf file:

<VirtualHost *:80>
DocumentRoot /path/to/drupal/install
ServerName ken.test
ServerAlias *.ken.test foo.test
</VirtualHost>

In this case any subdomain (*.ken.test) and another domain foo.test resolve to the same location. When configuring DNS for Domain Access, the document root is the same for all the VirtualHosts. The DocumentRoot directive sets the directory from which httpd will serve files. For DA, there is one Drupal installation and it is this installation built on a single database that is serving the files.

This becomes even clearer when the VirtualHosts are set up specifically, each with its own VirtualHost block in the httpd.conf file, for example:

<VirtualHost 127.0.0.1:80>
DocumentRoot /path/to/drupal/install
ServerName ken.test
</VirtualHost>

<VirtualHost 127.0.0.1:80>
DocumentRoot /path/to/drupal/install
ServerName two.ken.test
</VirtualHost>

<VirtualHost 127.0.0.1:80>
DocumentRoot /path/to/drupal/install
ServerName foo.test
</VirtualHost>

This example gives a general idea of what is involved, but it is beyond the scope of this document to explain how to configure your specific DNS server situation, which may involve considerable research, trial & error or a call for help. Shared server situations can be particularly complicated and you should contact their administration for help with configuration if their online help files do not make things clear enough.

After you have enabled multiple DNS entries to resolve to your single, default Drupal installation, you may activate the module and configure its settings at the Domains page (Drupal 7: Administration > Structure > Domains, or http://example.com/admin/structure/domain; Drupal 6: Administer > Build > Domains, or http://example.com/admin/build/domain).

Setting DOMAIN_INSTALL_RULE

This is an advanced instruction, and may be ignored.

At the top of the domain.module file, you will find this line:

define('DOMAIN_INSTALL_RULE', TRUE);

This setting controls the default behavior of the module when installing over an existing installation. If set to TRUE, the Domain Access module will assign all existing nodes to be viewable by your primary domain.

If you set this value to FALSE, existing content will not be visible on your primary domain unless DOMAIN_SITE_GRANT is set to TRUE.

Setting DOMAIN_SITE_GRANT

At the top of the domain.module file, you will find this line:

define('DOMAIN_SITE_GRANT', TRUE);

This setting controls the default behavior for viewing affiliate content. By design, the Domain Access module allows site administrators to assign content to 'all affiliates.' If this value is set to TRUE, then content assigned to all affiliates can be seen by all users on all current domains.

On install, setting this value to TRUE will assign all current content to be viewable on all domains.

Normally, you will not need to edit this value.

Setting DOMAIN_ASSIGN_USERS

At the top of the domain.module file, you will find this line:

define('DOMAIN_ASSIGN_USERS', TRUE);

After you install the Domain Access module, all new users who register will automatically be assigned to the domain from which their account was created. This value is used to determine advanced editing access and can be used by modules such as Domain Strict.

On install, setting this value to TRUE will assign all current users to be members of the default domain. Set the value to FALSE and the module will not assign users to any domains.

Normally, you will not need to edit this value.

After installation and configuration, users with the appropriate permissions may batch assign users to domains from People page in Drupal 7 (Administration > People, or http://example.com/admin/people) or the Users page in Drupal 6 (Administer > User Management > Users, or http://example.com/admin/user/user).

Help improve this page

Page status: No known problems

You can: