- Create a new database if you choose to have the subsite independent of the main Drupal site. Note that the sub-site can also use the same database of the main drupal site.
- Create a folder under the /drupal/sites/ folder. Note that I have assumed the drupal installation is on the root. Change the path as per your case. The new folder thus created has some naming constraints. For example, if the main drupal site's name is example.com and you wish to have a subsite by the name example.com/sub1, then the name of the folder will have to be "example.com.sub1". Copy the drupal/sites/default folder contents into the new example.com.sub1 folder.
- Open the settings.php file inside the /drupal/sites/example.com.sub1 folder. Remember to make this settings.php file writable, because Drupal will need the file to to writable in later steps of this process.Use >>sudo chmod 666 setting.php in a shell program to make the file writable if you need root user rights.
- Find the line that sets the db_url. Change the database name to the new database created in Step1. Change the base_url to "www.example.com/sub1" . Not that the base_url should not have a trailing slash after "sub1". Drupal automatically adds it. Save the settings.php file and close it. We will not be doing any more changes to the settings.php file.
- Open the .htaccess file under /drupal (where ever drupal has been installed).
- Add the following redirect rules to the .htaccess file:
- RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/sub1/.*
RewriteRule ^(.*)$ /sub1/index.php?q=$1 [L,QSA]
Note that the RewriteBase / might already be there in the .htaccess file. If it is there and is commented, un-comment it. Make sure the RewriteEngine is on as well. Save the file.
8. Using Putty or any shell program, change directory to the folder where drupal is installed. For example if drupal is installed in the root of the server, go to the root and create a Symlink (symbolic link) by typing the command below ln -s . sub1 The line above creates a symlink by the name sub1 that points to the drupal root. What this actually means is, the sub-site will share the same Drupal codebase, however has its own database and other settings. We can even create separate themes and modules folder under sites/example.com.sub1 folder and place the sub-site specific themes and modules there. Go to www.example.com/sub1/install.php in a browser. You will be led through the normal Drupal installation process. Making the settings.php fle writable as part of the step 3, helps here. Note that Drupal is installed for the subsite, from the same single Drupal codebase. Any updates done to Drupal's codebase such as maintenance tasks, will be applied to all the sites. Good Luck..!
0 comments:
Post a Comment