Drupal は、設定ファイル settings.php を除き、
設定情報やコンテンツはすべてデータベースに入っているので、リファレンスモデルとなるサイトを作って(すなわち、インストールした直後または、少しの修正をほどこしたサイト)、そこでできたデータベースまたはテーブルをコピーすればよい。
まずは雛形となるサイト(https://template.yourdomain.com など)を作る。その後、settings.php の内容を修正したものを適切なディレクトリにコピーしてから、https://newsite.yourdomain.com/install.php を走らせる。
以下はサイトを複製する SQL スクリプト。仕様としては、
- コピー元となるサイト
- データベース名: drupal
- テーブル名のプリフィックス: template_
- コピー先のサイト
- データベース名: drupal
- テーブル名のプリフィックス: newsite_
このスクリプトを実行すると
サイトを大量生産できるのだ。
CREATE TABLE `drupal`.`newsite_accesslog` ( `aid` int( 11 ) NOT NULL auto_increment ,
`sid` varchar( 64 ) NOT NULL default '',
`title` varchar( 255 ) default NULL ,
`path` varchar( 255 ) default NULL ,
`url` varchar( 255 ) default NULL ,
`hostname` varchar( 128 ) default NULL ,
`uid` int( 10 ) unsigned default '0',
`timer` int( 10 ) unsigned NOT NULL default '0',
`timestamp` int( 10 ) unsigned NOT NULL default '0',
PRIMARY KEY ( `aid` ) ,
KEY `accesslog_timestamp` ( `timestamp` ) ) ENGINE = MyISAM DEFAULT CHARSET = utf8;
CREATE TABLE `drupal`.`newsite_profile_fields` ( `fid` int( 11 ) NOT NULL auto_increment ,
`title` varchar( 255 ) default NULL ,
`name` varchar( 128 ) default NULL ,
`explanation` text,
`category` varchar( 255 ) default NULL ,
`page` varchar( 255 ) default NULL ,
`type` varchar( 128 ) default NULL ,
`weight` tinyint( 4 ) NOT NULL default '0',
`required` tinyint( 4 ) NOT NULL default '0',
`register` tinyint( 4 ) NOT NULL default '0',
`visibility` tinyint( 4 ) NOT NULL default '0',
`autocomplete` tinyint( 4 ) NOT NULL default '0',
`options` text,
PRIMARY KEY ( `fid` ) ,
UNIQUE KEY `name` ( `name` ) ,
KEY `category` ( `category` ) ) ENGINE = MyISAM DEFAULT CHARSET = utf8;
CREATE TABLE `drupal`.`newsite_profile_values` ( `fid` int( 10 ) unsigned default '0',
`uid` int( 10 ) unsigned default '0',
`value` text,
KEY `uid` ( `uid` ) ,
KEY `fid` ( `fid` ) ) ENGINE = MyISAM DEFAULT CHARSET = utf8;
DELETE FROM `drupal`.`newsite_accesslog`;
DELETE FROM `drupal`.`newsite_access`;
DELETE FROM `drupal`.`newsite_blocks`;
DELETE FROM `drupal`.`newsite_blocks_roles`;
DELETE FROM `drupal`.`newsite_filters`;
DELETE FROM `drupal`.`newsite_filter_formats`;
DELETE FROM `drupal`.`newsite_menu`;
DELETE FROM `drupal`.`newsite_permission`;
DELETE FROM `drupal`.`newsite_profile_fields`;
DELETE FROM `drupal`.`newsite_profile_values`;
DELETE FROM `drupal`.`newsite_role`;
DELETE FROM `drupal`.`newsite_sequences`;
DELETE FROM `drupal`.`newsite_system`;
DELETE FROM `drupal`.`newsite_users`;
DELETE FROM `drupal`.`newsite_variable`;
INSERT INTO `drupal`.`newsite_accesslog` SELECT * FROM `drupal`.`template_accesslog`;
INSERT INTO `drupal`.`newsite_access` SELECT * FROM `drupal`.`template_access`;
INSERT INTO `drupal`.`newsite_blocks` SELECT * FROM `drupal`.`template_blocks`;
INSERT INTO `drupal`.`newsite_blocks_roles` SELECT * FROM `drupal`.`template_blocks_roles`;
INSERT INTO `drupal`.`newsite_filters` SELECT * FROM `drupal`.`template_filters`;
INSERT INTO `drupal`.`newsite_filter_formats` SELECT * FROM `drupal`.`template_filter_formats`;
INSERT INTO `drupal`.`newsite_menu` SELECT * FROM `drupal`.`template_menu`;
INSERT INTO `drupal`.`newsite_node` SELECT * FROM `drupal`.`template_node`;
INSERT INTO `drupal`.`newsite_node_access` SELECT * FROM `drupal`.`template_node_access`;
INSERT INTO `drupal`.`newsite_node_comment_statistics` SELECT * FROM `drupal`.`template_node_comment_statistics`;
INSERT INTO `drupal`.`newsite_node_revisions` SELECT * FROM `drupal`.`template_node_revisions`;
INSERT INTO `drupal`.`newsite_node_type` SELECT * FROM `drupal`.`template_node_type`;
INSERT INTO `drupal`.`newsite_permission` SELECT * FROM `drupal`.`template_permission`;
INSERT INTO `drupal`.`newsite_profile_fields` SELECT * FROM `drupal`.`template_profile_fields`;
INSERT INTO `drupal`.`newsite_profile_values` SELECT * FROM `drupal`.`template_profile_values`;
INSERT INTO `drupal`.`newsite_role` SELECT * FROM `drupal`.`template_role`;
INSERT INTO `drupal`.`newsite_sequences` SELECT * FROM `drupal`.`template_sequences`;
INSERT INTO `drupal`.`newsite_system` SELECT * FROM `drupal`.`template_system`;
INSERT INTO `drupal`.`newsite_users` SELECT * FROM `drupal`.`template_users`;
INSERT INTO `drupal`.`newsite_variable` SELECT * FROM `drupal`.`template_variable`;
UPDATE `drupal`.`newtable_sequences` SET `name` = 'newtable_users_uid' WHERE CONVERT( `newtable_sequences`.`name` USING utf8 ) = 'template_users_uid' LIMIT 1 ;
UPDATE `drupal`.`newtable_sequences` SET `name` = 'newtable_menu_mid' WHERE CONVERT( `newtable_sequences`.`name` USING utf8 ) = 'template_menu_mid' LIMIT 1 ;
UPDATE `drupal`.`newtable_sequences` SET `name` = 'newtable_node_nid' WHERE CONVERT( `newtable_sequences`.`name` USING utf8 ) = 'template_node_nid' LIMIT 1 ;
UPDATE `drupal`.`newtable_sequences` SET `name` = 'newtable_node_revisions_vid' WHERE CONVERT( `newtable_sequences`.`name` USING utf8 ) = 'template_node_revisions_vid' LIMIT 1 ;
トラックバック URL:
https://perltips.twinkle.cc/trackback/243