// $Id: INSTALL.txt,v 1.6 2008-02-09 15:18:02 agentken Exp $ /** * @file * INSTALL file for Domain Access. */ Domain Access A subdomain-based access control system. CONTENTS -------- 1. Introduction 2. Installation 2.1 Before Installing 2.2 Server Configuration 2.3 Setting DOMAIN_INSTALL_RULE 2.4 Setting DOMAIN_EDITOR_RULE 2.5 Setting DOMAIN_SITE_GRANT 3. Patches to Drupal Core 3.1 multiple_node_access.patch 3.2 custom_url_rewrite_outbound.patch 4. Configuring settings.php 4.1 $base_url 4.2 $db_prefix 4.3 $cookie_domain 4.4 custom_url_rewrite_outbound() 4.4.1 Installation 4.4.2 Option 1 4.4.3 Option 2 4.4.4 Testing Your Configuration 4.4.5 Additional Resources 5. Additional Module Installation 5.1 Domain Configuration 5.2 Domain Prefix 5.3 Domain Strict 6. Uninstalling 7. custom_url_rewrite_outbound() function ---- 1. Introduction The Domain Access module is a Node Access module. It is designed to restrict access to content. Failure to install or uninstall this module according to instructions may cause errors in your site. ---- 2. Installation 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. When you enable the module, it will create a {domain} table in your Drupal database. All existing nodes on your site will be assigned to the default domain for your web site and to all affiliates. If you wish to alter this behavior, see sections 2.4 through 2.6 of README.txt ---- 2.1 Before Installing You will need to do the following before you install the module. - Read this document - Configure your web server DNS records appropriately - Read the supplied README.txt ---- 2.2 Server Configuration For the module to work correctly, the DNS record of your server must accept multiple DNS entries pointing at a single IP address that hosts your Drupal installation. The two basic methods for doing this are either to: - Setup WildCard DNS, so that *.example.com resolves to your Drupal site. - Setup VirtualHosts so that one.example.com, two.example.com, etc. all resolve to your Drupal site. For example, on my local testing machine, I have VirtualHosts to the following sites setup in httpd.conf (and my hosts file, to allow the .test TLD): - ken.test => 127.0.0.1 - one.ken.test => 127.0.0.1 - two.ken.test => 127.0.0.1 - three.ken.test => 127.0.0.1 It is beyond the scope of this document to explain how to configure your DNS server. For more information, see: - http://en.wikipedia.org/wiki/Wildcard_DNS_record - http://en.wikipedia.org/wiki/Virtual_hosting After you have enabled multiple DNS entries to resolve to your Drupal installation, you may activate the module and configure its settings. NOTE: No matter how many domains resolve to the same IP, you only need one instance of Drupal's settings.php file. The sites folder should be named 'default' or named for your root domain. ---- 2.3 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 all affiliate sites. If you set this value to FALSE, existing nodes will only be visible to users on your root domain. For more details, see section 5 of README.txt. ---- 2.4 Setting DOMAIN_EDITOR_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_EDITOR_RULE', FALSE); This setting controls the default behavior for affiliate editors. If DOMAIN_INSTALL_RULE is set to FALSE, you may change this value to TRUE if you intend to use editing controls. If this is set to TRUE, all existing nodes on your site will be editable by users who are assigned as editors of your root domain. See section 3 and section 5 of README.txt for more information. ---- 2.5 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. Normally, you will not need to edit this value. ---- 3. Patches to Drupal Core The following patches are optional. They affect advanced behavior of the Domain Access module. Patches are distributed in the 'patches' folder of the download. To apply these patches, place them in your root Drupal folder. Then follow the instructions at: http://drupal.org/patch/apply ---- 3.1 multiple_node_access.patch You should apply this patch only if you use Domain Access along with another Node Access module, such as Organic Groups (OG). The multiple_node_access.patch allows Drupal to run more than one node access control scheme in parallel. Instead of using OR logic to determine node access, this patch uses subselects to enable AND logic for multiple node access rules. WARNING: This patch uses subselect statements and requires pgSQL or MySQL 4.1 or higher. Developers: see http://drupal.org/node/191375 for more information. This patch is being submitted to Drupal core for version 7. ---- 3.2 custom_url_rewrite_outbound.patch This patch is only needed if: -- You wish to allow searching of all domains from any domain. -- You use a content aggregation module such as MySite. -- You get "access denied" errors when linking to items on a user's Track page. -- You want to turn on the advanced setting "Search Engine Optimization" to avoid content from being indexed on multiple domains. This patch allows modules to edit the path to a Drupal object. In the above cases, some content can only be viewed from certain domains, so we must write absolute links to that content. This patch introduces backports custom_url_rewrite_outbound() to Drupal 5. After you install this patch, you must copy the function: custom_url_rewrite_outbound() And paste it into your site's settings.php file. The entire function can be found at the end of this document. Developers: see http://drupal.org/node/207330 for more information. ---- 4. Configuring settings.php Remember, the Domain Access module lets you run multiple sites from a single installation. You only need one settings.php file. As a result, some options in your settings.php file need to be considered carefully. ---- 4.1 $base_url The $base_url setting is normally not set. With Domain Access, you cannot set this value manually. Since mutliple domains are involved, Drupal needs to be allowed to set this value. (For the technical, this happens in the conf_init() function). ---- 4.2 $db_prefix The $db_prefix value allows for table prefixing of your Drupal database in the event that you run more than one site from a single database. $db_prefix can be used normally with Domain Access. However, the Domain Prefix module provides for dynamic table prefixing based on the currently active domain. If you use the Domain Prefix module you can only set $db_prefix as a string value, not an array. For more detail, see INSTALL.txt in the domain_prefix folder. ---- 4.3 $cookie_domain By design, Drupal cookies are set for the current website on login. That is, if you login from www.example.com, the cookie will be set from the domain 'www.example.com.' However, a cookie from www.example.com is not valid on one.example.com. In order to provide for login across your active domains, you must set the $cookie_domain value to the string indicating your root domain. Typically, this value is '.example.com'. ---- 4.4 custom_url_rewrite_outbound() If you applied the custom_url_rewrite_outbound.patch, you must enable the function inside your settings.php file. The easiest way to do this is by using a PHP include to the file provided. ---- 4.4.1 Installation In the Domain Access download, find the following file: domain > settings_custom_url.inc You will need to load this file from inside your settings.php file. There are two methods for this. ---- 4.4.2 Option 1 -- Preferred This method is preferred, since any updates to the module release will be reflected in this file. NOTE: the elements inside the ==== marks are php code that should be copied into your settings.php file. DO NOT COPY THE ==== MARKS. Add the following lines to the end of your settings.php file: ==== /** * Add the custom_url_rewrite_outbound function. */ require_once './path/to/modules/domain/settings_custom_url.inc'; ==== In this case, change 'path/to/modules' with the directory where your modules are stored. Typically this will be 'sites/all/modules', which makes the lines: ==== /** * Add the custom_url_rewrite_outbound function. */ require_once './sites/all/modules/domain/settings_custom_url.inc'; ==== ---- 4.4.3 Option 2 If you are having difficulty determining the correct path, copy the file into your settings folder. domain > settings_custom_url.inc The file should be in the same directory as your active settings.php file. Then add the following lines: ==== /** * Add the custom_url_rewrite_outbound function. */ require_once 'settings_custom_url.inc'; ==== ---- 4.4.4 Testing Your Configuration After editing your settings.php file, go to Admin > Build > Domains. If you see a warning at the top of the page beginning: "The custom_url_rewrite_outbound() patch is not installed..." This message means that your PHP server cannot find the include file. You may need to test other path options for the include code. ---- 4.4.5 Additional Resources If you are having trouble configuring the include, you should check your PHP include path. You may need to use an absolute path to your server root. http://us3.php.net/manual/en/ini.core.php#ini.include-path You may also copy the entire function custom_url_rewrite_outbound() directly into your settings.php file. ---- 5. Additional Module Installation The Domain Access module includes several sub-modules. Two of these have their own INSTALL.txt instructions. ---- 5.1 Domain Configuration Refer to domain > domain_conf > INSTALL.txt ---- 5.2 Domain Prefix Refer to domain > domain_prefix > INSTALL.txt ---- 5.3 Domain Strict While this module requires no additional installation, it fundamentally changes the behavior of the Domain Access module. Under Domain Strict, only authenticated users (those who have registered) are given any domain-specific privileges. Anonymous users will only be able to view content that is assigned to "all affiliates." As a result, enabling this module may cause content to disappear from your site for users who are not logged in. This is by design. Refer to domain > domain_strict > README.txt ---- 6. Uninstalling When you disable this module, it will reset your {node_access} tables and remove all records from the {domain_access} table. This will remove all access rules associated with this module. You may then uninstall the module normally. You should also revert the patches that you applied and remove any extra code from your settings.php file. To revert a patch, see http://drupal.org/patch/reverse