前面介绍了怎么安装coreseek,下面介绍一下安装php sphinx扩展:
第一步:安装libsphinxclientcd coreseek-3.2.14/csft-3.2.14/api/libsphinxclient //这是coreseek的源码目录
./configure --prefix=/usr/local/sphinxclient
make && make install
如果有报错,按照错误提示处理
第二步:安装php sphinx 扩展wget
tar xf sphinx-1.3.3.tgz
cd sphinx-1.3.3
phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/sphinxclient
make && make install
安装好了之后在php.ini里面添加一行然后重启php-fpm,前提是extension_dir已经配置好了哈:extension=sphinx.so
第三步:php调用示例<?php
$client = new SphinxClient;
$client ->setServer("127.0.0.1", 9312);
$client ->setMatchMode(SPH_MATCH_PHRASE);
$client ->setMaxQueryTime(20);
$res = $client ->query("彭超",'kpost');
$error = $client ->GetLastError();
var_dump(array_keys($res['matches']));
var_dump($err);
?>
这就是简单的安装调用示例了,详细的大家可以查阅官方文档。
原创文章如转载,请注明出处,本文首发于彭超的博客
打赏
微信扫一扫,打赏作者吧~