multi-site

multi-site 要如何共用 user 帳號密碼

multi-site 共用同一個 mysql 的話, 例如:
site1:

<?php
//settings.php:
$db_url = 'mysql://root@127.0.0.1/site1';
$db_prefix = array(
       
'default' => '',
       
'users' => 'shared_',
       
'sessions' => 'shared_'
);
?>

site2:

<?php
//settings.php:
$db_url = 'mysql://root@127.0.0.1/site2';
$db_prefix = array(
       
'default' => '',
       
'users' => 'site1.shared_',
       
'sessions' => 'site1.shared_'
);
?>

Apache solr 多站設定 multi core setup

在 solr 的詞彙裏面, mulit site 的意思是指一個實體 solr 對應多個網站
和 apache virtual host 類似,
所以你可以同一部機器的一個 solr 放置數個站, 方便管理

而 solr 自帶的 example 資料夾本身已經有一個 multi site 的範例
而要認識 mutli core 的設定, 便先要了解 solr 的預設檔案結構:

start.jar
solr/
--conf/
----schema.xml
----solrconfig.xml

這邊只列出重要的檔案, 其中的 schema.xml 和 solrconfig.xml 都應該要換成 Drupal 自帶的
這是單站的設定, 而多站的設定:
start.jar
solr/
solr.xml
--core0/
----conf/
------schema.xml
------solrconfig.xml
--core1/
----conf/
------schema.xml
------solrconfig.xml

多出了一個 solr.xml 和個資料夾, core0 和 core1

solr.xml 內定義了:

<cores adminPath="/admin/cores">
  <core name="core0" instanceDir="core0" />
  <core name="core1" instanceDir="core1" />
</cores>

對應建立兩個資料夾, 和對應的兩個資料夾名稱
再將 conf 複製便完成了
打開 jetty 之後, 你可以到 /solr/core0/admin, /solr/core1/admin 確認成功設定
而 Drupal 內的 solr path 也需要對應輸入新的 subfix

順帶一提, core0 core1 的命名是不理想的,
應該使用例如 blog, uat, live 之類更加清晰的命名
core0 core1 的命名只是為了簡單解說而已

Move / convert drupal multi site to separate instances (從 multi sites 分成多個 Drupal)

ok, multi sites is just too difficult to manage
我承認 multi sites 是太難管理了, 它帶來的好處比不上它的壞處:

1. file paths are crazy
2. upgrade and development of one of the multi sites are potentially dangerous
1. 檔案路徑太混亂
2. 為其中一個site 的模組升級和開發有可能影響到其他 sites, 需要很小心

so steps to convert multi sites settings to separate Drupal instance:
要從 multi sites 分成多個 Drupal:

1. copy files into separate sub folders
2. edit each sub folder's settings file to point to correct db and use correct base path
3. maybe change the file paths of css and images in themes
4. turn off rewrite rules
5. delete old files, except folders named "files"
1. 複製原本的檔案到新建的子資料夾
2. 修改每個子資料夾的 settings.php 以使用正確的 DB 和 base path
3. 選擇性的修改 themes 內的 css 和圖片路徑
4. 拿掉 rewrite
5. 移除舊體制的資料夾, 除了以 "files" 來命名的資料夾

it is not very painful and difficult, but absolutely worth to test before do it in live sites
雖然這不是一個複雜的工作, 但都强烈建議先測試才在 live 環境工作

[2009-01-12] Drupal localhost 多站開發, Drupal localhost multi-site config

作為一個 Drupal developer, 通常都有幾個開發同時進行
一般人可能會用htdocs/[folder] 名
例如 http://localhost/drupal6, http://localhost/drupal5
或者案子名 http://localhost/blog 等等
但萬一core 要更新, 或者cck, views 有更新
便要更數個站, 實在麻煩

大家都或者知道 Drupal 是可以設定 multi-site 的
即是, 同一套code 可以供給兩個站使用 ( 例如 example1.com 和 example2.com )
優點很簡單, 模組更新的時候, 只要更新一次便可以令兩個完全不相關的 Drupal 站更新模組
而兩站可以使用完全不同的模版, 完全不同的資料庫
只是共用 core 和某些常用的模組 (例如views, cck 之類)

你的 drupal-root 內的 sites 資料夾,
可以建立 all, example1.com, example2.com 等等的資料夾
all 內的 modules, themes 是供放多站共用的資料
而 example1.com 內也可以建立 modules, themes 資料夾, 放這個域名專用的模組

所以現在只要將某個domain 指到 localhost
便可以實現 http://blog.localhost/drupal6, http://shop.localhost/drupal6.........

到 C:\WINDOWS\system32\drivers\etc\hosts
127.0.0.1 blog.localhost
127.0.0.1 shop.localhost
...
..

再在 htdocs/drupal6/sites/blog.localhost/ 內建一個 settings.php 便可以了
便可以 http://blog.localhost/drupal6/install.php

相關資源
http://drupal.org/getting-started/6/install/multi-site