1、下载
[root@localhost sphinx]# wget http://pecl.php.net/get/sphinx-1.0.4.tgz
[root@localhost sphinx]# tar zxvf sphinx-1.0.4.tgz
[root@localhost sphinx]# cd sphinx-1.0.4
[root@localhost sphinx-1.0.4]# /usr/local/php533/bin/phpize
2、安装sphinxclient
[root@localhost sphinx]# cd sphinx-for-chinese-0.9.9-r2117
[root@localhost sphinx-for-chinese-0.9.9-r2117]# cd api
[root@localhost api]# cd libsphinxclient/
[root@localhost libsphinxclient]# ./config
make报错可以编辑sphinxclient.c解决:
sphinxclient.c:280: warning: previous declaration of 'sock_close' was here
[root@localhost libsphinxclient]# make
sphinxclient.c:1217: warning: static declaration of 'sock_close' follows non-static declaration
sphinxclient.c:280: warning: previous declaration of 'sock_close' was here
[root@localhost libsphinxclient]# vi sphinxclient.c
void sock_close ( int sock ); //前面加个static
[root@localhost libsphinxclient]# make
[root@localhost libsphinxclient]# make install
3、安装php扩展
[root@localhost sphinx]# cd sphinx-1.0.4
[root@localhost sphinx-1.0.4]# ./configure --with-php-config=/usr/local/php533/bin/php-config
[root@localhost sphinx-1.0.4]# make
[root@localhost sphinx-1.0.4]# make install
Installing shared extensions:
/usr/local/php533/lib/php/extensions/no-debug-non-zts-20090626/
4、编辑php.ini文件,加入sphinx.so扩展并重启php-fpm
[root@localhost php533]# cd etc
[root@localhost etc]# vi php.ini
[root@localhost etc]# ps -ef|grep php
nobody 9970 22641 0 16:44 ? 00:00:09 /usr/local/php533/sbin/php-fpm
[root@localhost etc]# kill -SIGINT 22641
[root@localhost etc]# /usr/local/php533/sbin/php-fpm
5、查看phpinfo输出,编程测试:
[root@localhost httppush]# vi sphinx.php
<?php
$s = new SphinxClient;
$s->setServer("localhost", 9312);
$s->setMatchMode(SPH_MATCH_ANY);
$s->setMaxQueryTime(3);
$result = $s->query("demo");
var_dump($result);
?>
One Response to 安装sphinx的php扩展小记
发表评论 取消回复
技术组织
最近评论
- passenger 发表在《一个完整的Oracle建表的例子》
- tudou 发表在《Oracle增大redo log file的方法》
- Yousri 发表在《如何在mac下长期使用SecureCRT》
- Amazon SES筆記 « What's Going On 发表在《如何使用Amazon的邮件服务SES》
- 如何使用Amazon的邮件服务SES | 半瓶 发表在《为Postfix增加DKIM功能》
- pary 发表在《为Postfix增加DKIM功能》
历史归档
广告位







[...] http://www.banping.com/2011/03/18/sphinx-php-extension/ [...]