how to create a multisite using drupal
1. my site is at http://www.mainsite.com
2. I want to create a subsite at http://www.mainsite.com/jp
3. I want to maintain the same users, sessions, roles for all my sub sites
4. I want to maintain same database for all my main site and subsites
procedure:
1. Back up your database first
2. Rename all your tables to en_tablename (english is one of my site)
3. Rename following tables to shared_tablename (as we are going to share users, sessions, roles, auth common to all sub sites)
users, sessions, role, authmap
example: shared_users, shared_sessions...
4. Create tables for sub site (you need to create duplicate of all tables with sub site prefix. jp_tablename for example)
example: jp_variable
5. create a folder mainsite.com.jp at sites/ folder
6. You can create following sub folders inside mainsite.com.jp/
files/
modules/
themes/
tmp/
You can use default/files folder if you dont want for every sub site.
7. Copy the default/settings.php to sites/mainsite.com.jp/settings.php
8. Have the following in sub site settings.php if you want to maintain all the sites in same database.
$db_prefix = array(
// 'default' => 'main_',
'default' => 'jp_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
);
$db_url = 'mysqli://root:username@localhost/dbname';
9. The main site settings.php should look like this.
$db_prefix = array(
// 'default' => 'main_',
'default' => 'en_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
);
$db_url = 'mysqli://root:username@localhost/dbname';
10. Create a symbolic link at drupal root installation folder
ln -s rootfolder subsitefolder
Example:
ln -s /home/webuser/htdocs/ /home/webuser/htdocs/jp
11. Now access the site at http://www.mainsite.com and http://www.mainsite.com/jp.
Both the sites now share common users, sessions but all the contents will be different. This is upto you what to share what not to share.
Note:
Here is the script to rename existing database tables to another name.
2. I want to create a subsite at http://www.mainsite.com/jp
3. I want to maintain the same users, sessions, roles for all my sub sites
4. I want to maintain same database for all my main site and subsites
procedure:
1. Back up your database first
2. Rename all your tables to en_tablename (english is one of my site)
3. Rename following tables to shared_tablename (as we are going to share users, sessions, roles, auth common to all sub sites)
users, sessions, role, authmap
example: shared_users, shared_sessions...
4. Create tables for sub site (you need to create duplicate of all tables with sub site prefix. jp_tablename for example)
example: jp_variable
5. create a folder mainsite.com.jp at sites/ folder
6. You can create following sub folders inside mainsite.com.jp/
files/
modules/
themes/
tmp/
You can use default/files folder if you dont want for every sub site.
7. Copy the default/settings.php to sites/mainsite.com.jp/settings.php
8. Have the following in sub site settings.php if you want to maintain all the sites in same database.
$db_prefix = array(
// 'default' => 'main_',
'default' => 'jp_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
);
$db_url = 'mysqli://root:username@localhost/dbname';
9. The main site settings.php should look like this.
$db_prefix = array(
// 'default' => 'main_',
'default' => 'en_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
);
$db_url = 'mysqli://root:username@localhost/dbname';
10. Create a symbolic link at drupal root installation folder
ln -s rootfolder subsitefolder
Example:
ln -s /home/webuser/htdocs/ /home/webuser/htdocs/jp
11. Now access the site at http://www.mainsite.com and http://www.mainsite.com/jp.
Both the sites now share common users, sessions but all the contents will be different. This is upto you what to share what not to share.
Note:
Here is the script to rename existing database tables to another name.
Comments
Post a Comment