Complete solution for Multisite in Drupal 7

  0 comments
Share

Sharing the same code base but different database

Consider You need structure like below in multisite: ---

A.    example.com
B.    example.com/site1   (One level subdirectory)
C.    example.com/abc/site2  (Two level subdirectory)
D.    example.com/def/xyz/site3  (Three level subdirectory)

To create a new site using a shared Drupal code base you must complete the following easy steps: ---

Installation Guide for the default site ‘A’ example.com

1.    Create a new database for the site example.com and install as normal Drupal installation.

Installation Guide for the site ‘B’ example.com/site1 (One level subdirectory)

2.    Create a new subdirectory within the 'sites' directory of the name of your new site site1Subdirectory name will be example.com.site1(hostname.subdir)
3.    Copy the file sites/default/default.settings.php into the subdirectory you created in the previous step. Rename the new file to settings.php.
4.    Adjust the permissions of the new site directory,and grant write permissions on the configuration file (sites/example.com.site1/settings.php).
Be sure to change the file's permissions back after you have run the installation script.
5.    Make symbolic links if you are using a subdirectory such as example.com/site1.
(See How to create symbolic linkssection below for details).
6.    In a Web browser, navigate to the URL of the new site (example.com/site1) and continue with the standard Drupal installation procedure and install it in a new database. (if you get an infinite redirection loop, check if the file install.php exists the document root).
7.    Set base_url in sites/example.com.site1/settings.php to example.com/site1
8.    Add these lines in .htaccess file of drupal core: ---
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteCond %{REQUEST_URI} ^/site1
    RewriteRule ^ site1/index.php [L]

Installation Guide for the site ‘C’ example.com/abc/site2(Two level subdirectory)

9.    Create a new subdirectory within the 'sites' directory of the name of your new site site2 Subdirectory name will be example.com.abc.site2(hostname.dir.subdir)
10.    Repeat step3 and step4.
11.    Make symbolic links if you are using a subdirectory such as example.com/abc/site2.
        (See How to create symbolic links section below for details).
12.    In a Web browser, navigate to the URL of the new site (example.com/abc/site2) and continue with the standard Drupal installation procedure and install it in a new database.
13.    Set base_url in sites/example.com.abc.site2/settings.php to example.com/abc/site2
14.    Add these lines in .htaccess file of drupal core: ---
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteCond %{REQUEST_URI} ^/abc.site2
    RewriteRule ^ abc.site2/index.php [L]

Installation Guide for the site ‘D’ example.com/def/xyz/site3(Three level subdirectory)

15.    Create a new subdirectory within the 'sites' directory of the name of your new site site2 Subdirectory name will be example.com.def.xyz.site3 (hostname.dir.subdir.subdir)
16.    Repeat step3 and step4.
17.    Make symbolic links if you are using a subdirectory such as example.com/def/xyz/site3.
        (See How to create symbolic links section below for details).
18.    In a Web browser, navigate to the URL of the new site (example.com/def/xyz/site3) and continue with the standard Drupal installation procedure and install it in a new database.
19.    Set base_url in sites/example.com.def.xyz.site3/settings.php to example.com/def/xyz/site3
20.    Add these lines in .htaccess file of drupal core: ---
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteCond %{REQUEST_URI} ^/def.xyz.site3
    RewriteRule ^ def.xyz.site3/index.php [L]
 

How to create symbolic links for multisite: ---

Create symbolic link for the site ‘B’ example.com/site1 (One level subdirectory)

To do this, go to the example.com document root and type: ---
    ln -s . site1

Create symbolic link for the site ‘C’ example.com/abc/site2 (Two level subdirectory)

To do this, go to the example.com document root and type: ---
    ln -s . abc.site2
    mkdir abc
    cd abc
    ln –s .. site2

Create symbolic link for the site ‘D’ example.com/def/xyz/site3 (Threelevel subdirectory)

To do this, go to the example.com document root and type: ---
    ln -s . def.xyz.site3
    mkdir def
    cd def
    ln –s .. xyz.site3
    mkdir xyz
    cd xyz
    ln –s ../xyz.site3 site3

 

Add new comment