顯示具有 Apache 標籤的文章。 顯示所有文章
顯示具有 Apache 標籤的文章。 顯示所有文章

2012年1月13日 星期五

Apache RewriteMap Usage

從 IP 判斷User的合約
ip_contract_map.txt 如下:第一欄為User IP,第二欄為合約ID
10.1.1.254 1
60.199.248.193 2
60.251.144.84 3
114.32.4.229 3

Apache設定:

...
#打開RewriteEngine
RewriteEngine on

#將 mapping 讀出來當成contracts這變數。
RewriteMap contracts txt:/srv/www/ip_contract_map.txt

#不覆寫原本的網址,直接用 User 的 IP 當成 key 去 mapping 裡面找。
# %{REMOTE_ADDR} 是遠端的IP
RewriteRule .* - [E=REDIRECT_CONTRACT_ID:${contracts:%{REMOTE_ADDR}}]
...

2011年8月1日 星期一

Apache使用Cronolog

參考:http://www.ylmf.net/linux/tips/2010111710026.html

安裝Cronolog:
  1. wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
  2. gzip -d cronolog-1.6.2.tar.gz
  3. tar xf cronolog-1.6.2.tar
  4. cd cronolog-1.6.2
  5. ls
  6. ./configure
  7. make
  8. make install
  9. which cronolog
which cronolog會看到被安裝在 /usr/local/sbin/cronolog
CustomLog "| /usr/local/sbin/cronolog /[PATH_TO_YOUR_LOG]/access-%Y%m%d.log" combined
 <VirtualHost *:80>
  ServerName ......
  DocumentRoot ......
  <Directory /Users/cateyes/work/sites/>
    ......
  </Directory>
  CustomLog "| /usr/local/sbin/cronolog /[PATH_TO_YOUR_LOG]/access-%Y%m%d.log" combined
</VirtualHost>

2011年5月24日 星期二

Solr Schema

<fields>:定義有哪些filed
<field>:定義該有的field,如果要用動態欄位可用<dynamicField>
  • name:必備,這個filed的名稱
  • type:必備,這個field的種類( boolean | string | int | float | long | double | date | point | ...)
  • indexed:選用,是否要用來作index
  • stored:選用,是否要儲存。通常在copyField指定的目標會設為false。
  • multiValued:選用,是否會有多個內容,如:(好折凳)產品功能可能會有好多個

<dynamicField>:定義模糊的field,如*_i、ignored_*,其他同field
如:age_i 就會對應到 *_i。

<copyField>:把某個 field 複製到某個 field 搜尋,通常會用在 copy 到 defaultSearchField。

<defaultSearchField>:定義預設的搜尋field

Solr Tips

什麼是Solr?
請參考http://mclee.foolme.net/2007/07/solr-enterprise-search.html

Solr用法
http://my.opera.com/jinglepot/blog/solr-schema-xml

注意!
改過 schema 後,要把
  1. solr 重新啟動
  2. 資料重新post進solr