`
syu
  • 浏览: 15920 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

在Ubuntu8.10下为PHP安装coreseek全文检索引擎支持的详细步骤

阅读更多

关于sphinx就不多累言了,一套相当优秀的全文检索引擎.无论索引速度还是检索速度真的是非常的快.


至于coreseek ,可访问李沫南的站点 http://www.coreseek.com
顺便在此感谢李沫南同学为sphinx中文化做的贡献 :0)

本文着重介绍在ubuntu下安装coreseek及相应的sphinx-php扩展.

具体示例应用另开文写.

以下安装环境基于 Ubuntu8.10 Server版,

操作用户使用root账户.
coreseek基于2008-09-26发布的3.0beta4版本

文中此颜色字体为需用户输入的命令内容
=========================================================

1.源码包准备
下载MMSEG分词源码包
wgethttp://www.coreseek.com/uploads/sources/mmseg3_0b3.tar.gz

下载coreseek源码包
wgethttp://www.coreseek.com/uploads/sources/csft3_0b4.tar.gz

解压缩源码包
tar -xzvf mmseg3_0b3.tar.gz
tar -xzvf csft3_0b4.tar.gz



2.安装环境准备

安装g++编译环境

apt-get install g++

apt-get install gcc

安装python开发组件

apt-get install python

apt-get install python-dev

安装mysql开发库

apt-get install libmysqlclient15-dev

安装PHP运行及支撑环境

apt-get install php5

apt-get install php5-dev

apt-get install php5-pear

安装make

apt-get install make

3.编译mmseg

cd mmseg.3.0b3/

./configure --prefix=/usr/local/mmseg

make

make install

注意:如果在这一步出错,且出错提示为:css/UnigramCorpusReader.cpp:89: error: 'strncmp' was not declared in this scope
则需手工编辑.src/css目录下UnigramCorpusReader.cpp 文件,在其第一行加上

#include <string.h>
然后重新 make,make install即可通过
在这一步安装完了后,将会在 /usr/local 下产生 mmseg目录,
手工修改 /usr/local/mmseg/include/mmseg/freelist.h
vi /usr/local/mmseg/include/mmseg/freelist.h
在上面添加
#include <string.h>
4.编译coreseek
cd csft3_0b4/
./configure --prefix=/usr/local/coreseek --with-python --with-mysql --with-mmseg-includes=/usr/local/mmseg/include/mmseg --with-mmseg-libs=/usr/local/mmseg/lib/
make & make install
在此过程中.可能会出现错误提示
sphinxutils.cpp:793: error: cannot convert ‘int*’ to ‘Py_ssize_t*’ for argument ‘2’ to ‘int PyDict_Next(PyObject*, Py_ssize_t*, PyObject**, PyObject**)’
sphinxutils.cpp:802: warning: unused variable ‘nRet’
make[2]: *** [sphinxutils.o] 错误 1
make[2]:正在离开目录 `/home/syu/sphinx/csft3_0b4/src'
make[1]: *** [all] 错误 2
make[1]:正在离开目录 `/home/syu/sphinx/csft3_0b4/src'
make: *** [all-recursive] 错误 1

这个时候,可以手工打开 src目录下的 sphinxutils.cpp 修改第789行左右
intpos = 0; --------->将此行修改为 Py_ssize_t pos = 0;

保重.重新make & make install 即可

此步安装完成后,将在/usr/local/下生成 coreseek 目录

5.安装sphinx client lib

先进入 coreseek的api下libsphinxclient目录

cd csft3_0b4/api/libsphinxclient

运行 buildconf.sh

chmod 0755 ./buildconf.sh

./buildconf.sh

./configure && make install


6,安装pecl-sphinx扩展库
pecl install sphinx-0.2.0
7.为PHP加上sphinx扩展
cd /etc/php5/conf.d
echo "extension= sphinx.so" >sphinx.ini
至此,sphinx的服务环境和PHP客户端均安装完毕.
可以在phpinfo中看到sphinx相关信息.
sphinx全文检索的中文教程请参考李沫南翻译的手册 :http://www.coreseek.cn/uploads/pdf/sphinx_doc_zhcn_0.9.pdf
PHP-sphinx相关调用函数请参阅php手册 http://www.php.net/manual/en/class.sphinxclient.php


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics