1、php的windoes sphinx扩展安装
下载dll文件,http://windows.php.net/downloads/pecl/releases/sphinx/1.3.3/
下载的文件放在php的ext目录下,在php.ini加上extension=php_sphinx.dll
php的linux
sphinx扩展安装
下载地址:http://pecl.php.net/package/sphinx
wgethttp://pecl.php.net/get/sphinx-1.3.0.tgz
tarzxf sphinx-1.3.0.tgz
cdsphinx-1.3.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config--with-sphinx=/usr/local/sphinx/
make&& make install
3、建立索引文件
2、
sphinx服务安装
CoreSeek官方网站:
http://www.coreseek.cn/
http://www.coreseek.cn/products/="/products-install/step_by_step/
http://www.coreseek.cn/products-install/mysql/
具体操作:
一、安装编译工具
yum install make gcc g++ gcc-c++ libtool autoconf automakeimake mysql-devel libxml2-devel expat-devel
二 、安装CoreSeek
1、下载CoreSeek
下载地址:http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz
2、安装mmseg
tar zxvf coreseek-3.2.14.tar.gz #解压
cd coreseek-3.2.14/
mmseg-3.2.14
./bootstrap #输出的warning信息可以忽略
./configure --prefix=/usr/local/mmseg3 #配置
make && make install #
#编译安装
3、安装CoreSeek
cd coreseek-3.2.14/csft-3.2.14
sh buildconf.sh #输出的warning信息可以忽略
./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#
#编译
安装
/usr/local/coreseek/bin/indexer-c
/usr/local/coreseek/etc/csft_mysql.conf --all# 生成全部索引文件的命令
/usr/local/coreseek/bin/indexer-c
/usr/local/coreseek/etc/csft_mysql.conf --all
--rotate
#--rotate:该参数可以使我们在不需要停止searchd的情况下,直接加载索引
/usr/local/coreseek/bin/indexer-c
/usr/local/coreseek/etc/csft_mysql.conf
--rotateindex_search_main
#生成主索引
/usr/local/coreseek/bin/indexer-c
/usr/local/coreseek/etc/csft_mysql.conf
--rotateindex_search_main_delta
#生成增量索引
/usr/local/coreseek/bin/indexer -c/
usr/local/coreseek/etc/csft_mysql.conf
--mergeindex_search_main index_search_main_delta --rotate
#增量索引和主索引的合并
/usr/local/coreseek/bin/searchd-c
/
usr/local/coreseek/etc/csft_mysql.conf
开启
/usr/local/coreseek/bin/searchd-c
/
usr/local/coreseek/etc/csft_mysql.conf
--stop为关闭
4、API调用
$index = 'test1';
$key = '北';
$sc = new SphinxClient();
$sc->SetServer('192.168.33.10',9312);
#$sc->SetMatchMode(SPH_MATCH_ALL);
$sc->SetMatchMode(SPH_MATCH_EXTENDED);
$sc->SetArrayResult(TRUE);
$res = $sc->Query($
key,$index);
$err = $sc->GetLastError();
print_r($res);
print_r($err);