Sphinx安装(For Linux)
一、准备工作
下载Sphinx:
Sphinx
下载中文分词:
mmseg-0.7.3
二、搜索引擎安装
编译安装Sphnix:
./configure --prefix=/usr/local/searchd --with-mysql=/usr/local/mysql
make
make install
如果在编译中出现下面错误:
/home/jling/sphinx-0.9.9/src/sphinx.cpp:20060: undefined reference to `libiconv_open'
/home/jling/sphinx-0.9.9/src/sphinx.cpp:20078: undefined reference to `libiconv'
/home/jling/sphinx-0.9.9/src/sphinx.cpp:20084: undefined reference to `libiconv_close'
collect2: ld returned 1 exit status
make[2]: *** [indexer] Error 1
make[2]: Leaving directory `/home/jling/sphinx-0.9.9/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/jling/sphinx-0.9.9/src'
make: *** [all-recursive] Error 1
请打开configure文件,找到“#define USE_LIBICONV 1”,将注释去掉,并将1改成0。
vi configure;
#define USE_LIBICONV 1改成define USE_LIBICONV 0
备注:可以线尝试下构造索引,如遇到如下报错信息:
[root@web3 etc]# /usr/local/searchd/bin/indexer --config /usr/local/searchd/etc/sphinx.conf demo
/usr/local/searchd/bin/indexer: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory
请做个软链接:
ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16
三、中文分词安装
./bootstrap
./configure --prefix=/usr/local/mmseg
make
make install
四、搜索引擎配置
五、生成中文字典
cd /usr/local/mmseg
./bin/mmseg -u unigram.txt
mv unigram.txt.uni uni.lib
六、程序集成(For PHP)