当前位置: 代码迷 >> 综合 >> sphinx 安装
  详细解决方案

sphinx 安装

热度:93   发布时间:2024-01-16 04:56:38.0
Requirements:


    - coreseek 3.2.14
        http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz
    - m4 >= 1.4.13
    - autoconf >= 2.65
    - automake >= 1.11
    - libtool >= 2.2.6b


On Debian 6.0.5(squeeze):


    coreseek 在 gcc (Debian 4.7.1-5) 4.7.1 下会因为变量作用域问题 make 不通过,请打 patch:
        $ cd csft-3.2.14 && patch -p0 csft-3.2.14_patch


Install:


    $ apt-get install automake libtool gcc g++ make mysql-client libmysqlclient15-dev libxml2-dev libexpat1-dev


    #
    # 分词包
    #
    $ cd mmseg-3.2.14
    $ ./bootstrap
    $ ./configure --prefix=/usr/local/mmseg3
    $ make && make install


    #
    # coreseek
    #
    $ cd csft-3.2.14
    $ sh buildconf.sh
    $ ./configure --prefix=/usr/local/coreseek  --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql
    $ make && make install


    #
    # 测试安装正确
    #
    $ cd testpack
    $ locale # 检查中文显示环境
    $ cat var/test/test.xml
    $ /usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc var/test/test.xml
    $ /usr/local/coreseek/bin/indexer -c etc/csft.conf --all
    $ /usr/local/coreseek/bin/search -c etc/csft.conf 关键词搜索


Grant mysql access:


    创建 sphinx_koubei 用户:
        CREATE USER 'sphinx_koubei'@'localhost' IDENTIFIED BY 'P@SSWORD';


    只需要 SELECT 权限:
        GRANT SELECT ON `koubei`.* TO 'sphinx_koubei'@'localhost';


Configuration:
    $ cp conf/env-example.conf conf/env.conf
    $ vi conf/env.conf


Startup:
    #
    # 设定 conf 后,install_startup 脚本将自动安装启动脚本到 /etc/init.d/
    # 同时创建 searchd 用户/组,及需要的目录。至此 coreseek 安装完成。
    #
    $ sudo ./scripts/install_startup




MMSeg ( for developer ):
    #
    # 测试分词结果
    #
    $ /usr/local/mmseg3/bin/mmseg -d <dict_dir> unigram.txt


    #
    # 从 unigram.txt 构造词典
    #
    $ /usr/local/mmseg3/bin/mmseg -u unigram.txt
    $ mv unigram.txt.uni uni.lib


    #
    # 构造特殊短语词库
    #
    $ /usr/local/mmseg3/bin/mmseg -b exceptions.txt
    $ mv synonyms.dat /path/to/uni.lib/dir


    #
    # 构造同义词库
    #
    $ ./scripts/build_thesaurus.py unigram.txt > thesaurus.txt
    $ /usr/local/mmseg3/bin/mmseg -t thesaurus.txt
    $ mv thesaurus.lib /path/to/uni.lib/dir