转载自:http://blog.csdn.net/liruxing1715/article/details/8464313
linux 环境为: CentOS 5.5
1、软件下载
>>> 点击下载
2、安装 sphinx
- tar zxvf sphinx-0.9.9.tar.gz //解压sphinx包
- cd sphinx-0.9.9
- ./configure --prefix=/usr/local/sphinx --with-mysql=/usr/local/mysql/
--prefix:指定 sphinx 的安装路径
--with-mysql:指定 mysql 安装路径
- make && make install
安装成功之后,sphinx 会形成三个命令:
indexer 创建索引命令
searchd 启动进程命令
search 命令行搜索命令
3、配置 sphinx
- cd /usr/local/sphinx/etc
进入 sphinx 的 etc 目录下
- cp sphinx.conf.dist sphinx.conf
拷贝一份配置文件,并且命名为 sphinx.conf
修改配置信息
4、安装 coreseek
- tar zxvf coreseek-3.2.14.tar.gz
解压会出现两个目录:csft-3.2.14、mmseg-3.2.14
先安装 mmseg
- cd mmseg-3.2.14/
- ./configure --prefix=/usr/local/mmseg
编译如果出现错误:“config.status: error: cannot find input file: src/Makefile.in”
解决方案:http://www.9enjoy.com/install_coreseek-3_2_13/
- make && make install
安装 csft(coreseek)
- cd csft-3.2.14/
- ./configure --prefix=/usr/local/coreseek --with-mysql=/usr/local/mysql/ --with-mmseg=/usr/local/mmseg/ --with-mmseg-includes=/usr/local/mmseg/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg/lib/
- make && make install
默认 coreseek 加载的配置文件是 csft.conf
使用 sphinx 需要做以下几件事
1.有数据;
2.建立 sphinx 配置文件;
3.生成索引;
4.启动 searchd 服务进程,默认是9312
5.用 PHP 去连接 sphinx 服务
启动 sphinx
- cd /usr/local/coreseek/bin/
- ./searchd
启动命令
searchd 命令参数介绍:
-c 指定配置文件
--stop 停止服务
--pidfile 用来显式指定一个 PID 文件
-p 指定端口
5、php 加载 sphinx 模块
- tar zxf sphinx-1.1.0.tgz
- cd sphinx-1.1.0
- /usr/local/php/bin/phpize
- ./configure --with-php-config=/usr/local/php/bin/php-config
如果出现错误:“configure: error: Cannot find libsphinxclient headers”
解决方法:
- cd /tmp/lamp/coreseek-3.2.14/csft-3.2.14/api/libsphinxclient/
- ./configure
- make && make install
解决完毕!
回去接着执行
- ./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx
- make && make install
出现类似“Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/”,表示成功。
可以进入该目录下会发现生成了一个 sphinx.so 文件
在 php.ini 中加载该 so 文件
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/sphinx.so
重启 apache ,phpinfo() 中出现这个表明成功。