flybird119 / libra-server

Automatically exported from code.google.com/p/libra-server
1 stars 0 forks source link

CentOS下安装步骤 #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
操作系统:CentOS

1. 安装libevent http://monkey.org/~provos/libevent/

  yum install libevent.x86_64  libevent-devel.x86_64 libevent.i686  libevent-devel.i686

2、安装libiconv

  由于libdatrie依赖于libiconv来实现编码转换,因此必须安装libiconv

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure
make
make install

2.安装libdatrie http://linux.thai.net/~thep/datrie/datrie.html

wget  ftp://linux.thai.net/pub/ThaiLinux/software/libthai/libdatrie-0.2.4.tar.gz

tar zxvf  libdatrie-0.2.4.tar.gz

cd libdatrie-0.2.4

./configure CFLAGS=-liconv

make 

make install

3、安装libra-server

  mkdir libra-server

  cd  libra-server

  wget https://libra-server.googlecode.com/files/libra-server-v1.1.zip

  unzip libra-server-v1.1.zip

  make 

  echo  "/usr/local/lib"  >>/etc/ld.so.conf

  /sbin/ldconfig -v

启动matcher server:./matcher

4、测试

将matcher.php拷贝到web服务器对应目录下,并在目录下创建以下
测试代码。文件采用UTF-8无BOM编码格式存储

   a、创建初始化过滤关键词库的代码 initdb.php

<?php

include('matcher.php');

$matcher = new Matcher('127.0.0.1');

$matcher->set('法轮功');

$matcher->set('共产党');

$matcher->set('江泽民');

$matcher->set('美女');

$matcher->set('测试');

$matcher->set('fuck');

?>

  b、创建搜索测试代码 search.php

<?php

include('matcher.php');

$matcher = new Matcher('127.0.0.1');

$matchs = $matcher->gets('测试代码,法轮功。fuck');

if (!empty($matchs)) {

   print_r($matchs);

}

?>

Original issue reported on code.google.com by chuanli...@gmail.com on 27 Oct 2012 at 1:15

GoogleCodeExporter commented 9 years ago
1.关键词库不可以直接在txt里寻找吗?这样一个一个添加太麻��
�了吧,在网上打的都是txt文档,从上到下列出来的,都得前�
��添加$matcher->set('关键词');不编个程序都不好添加啊,几万个
关键词,手动搞会出人命的。
2.Code license
Apache License 2.0
这个与apache有关系吗?我用的nginx可以用吗?
谢谢!

Original comment by myit...@gmail.com on 4 Oct 2013 at 4:14