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解决:

[root@localhost libsphinxclient]# make
make  all-am
make[1]: Entering directory `/home/zoudp/sphinx/sphinx-for-chinese-0.9.9-r2117/api/libsphinxclient'
/bin/sh ./libtool --mode=compile --tag=CC gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c -o sphinxclient.lo sphinxclient.c
mkdir .libs
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c sphinxclient.c  -fPIC -DPIC -o .libs/sphinxclient.o
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]# 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扩展小记

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>