1. 程式人生 > >Centos下安裝php擴展sphinx

Centos下安裝php擴展sphinx

問題 for strings () form let rect orm 必須

官方地址:http://pecl.php.net/package/sphinx

wget http://pecl.php.net/get/sphinx-1.3.3.tgz
tar -zxvf sphinx-1.3.3.tgz

安裝php擴展必須有php-devel,沒有php-devel就缺少phpize,就不會產生源代碼文件,yum安裝測試一下

yum install php-devel
cd /usr/local/src/coreseek-4.1-beta/testpack/api/libsphinxclient/
./configure
checking for strings.h... (cached) yes
checking for unistd.h... (cached) yes
checking for stdint.h... (cached) yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sphinxclient_config.h
config.status: executing depfiles commands
make && make install
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
test -z "/usr/local/include" || mkdir -p -- "/usr/local/include"
 /usr/bin/install -c -m 644 ‘sphinxclient.h‘ ‘/usr/local/include/sphinxclient.h‘
make[1]: Leaving directory `/usr/local/src/coreseek-4.1-beta/testpack/api/libsphinxclient‘
cd /usr/local/src/sphinx-1.3.3
phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
./configure --with-php-config=/usr/bin/php-config --with-sphinx
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
make && make install
Build complete.
Don‘t forget to run ‘make test‘.
Installing shared extensions:     /usr/lib64/php/modules/

生成的文件

技術分享

cd /etc/php.d/      //還需要修改配置文件
vim sphinx.ini    //下面兩行寫入該文件
; Enable gd extension module
extension=sphinx.so

php是apache的模塊,sphinx又是php的擴展。重啟apache即可

技術分享

完畢

-------求助~~~~~-------

<?php

// echo phpinfo();
header("Content-type:text/html;charset=utf-8");
echo ‘<pre>‘;
$sphinx_obj     = new SphinxClient();
$sphinx_obj->setServer(‘127.0.0.1‘,9312);
$sphinx_obj->setMatchMode(SPH_MATCH_ANY);
$res    = $sphinx_obj->query(‘php‘,‘*‘);
var_dump($sphinx_obj);
exit();

技術分享

百度、必應、google、搜狗、360都搜過了,遇到同樣的求助問題,但一直沒有解決方案~~不知道哪裏錯了~前輩們看到請留下您的腳步~謝謝哈~

Centos下安裝php擴展sphinx