安装php扩展sphinx-1.2.0.tgz和libsphinxclient0.9.9


一.首先安装libsphinxclient(php模块需要)


cd /usr/local/src/
tar zxvf sphinx-0.9.9.tar.gz
cd sphinx-0.9.9/api/libsphinxclient/
./buildconf.sh
./configure
make
make install


安装过程中如果报下面的错:


修改sphinxclient.c:280行,void前面加上static声明

/usr/local/src/sphinx-0.9.9/api/libsphinxclient/sphinxclient.c line 280


But when I used "sudo make" I got this error:
sphinxclient.c:1216: error: static declaration of ‘sock_close’ follows non-static
declaration
sphinxclient.c:280: note: previous declaration of ‘sock_close’ was here

So I checked the file.

On line: 280
void sock_close ( int sock );

On line: 1216
static void sock_close ( int sock )
{
#if _WIN32
closesocket ( sock );
#else
close ( sock );
#endif
}

I changed the line 280 to:
static void sock_close ( int sock );

Then I could compile it without any errors.

二.安装PHP Sphinx 扩展模块


cd /usr/local/src/
tar zxvf sphinx-1.2.0.tgz
cd sphinx-1.2.0
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config --with-sphinx=/usr/local/sphinx
make
make install

PHP配置

修改PHP.ini,
1.如果以前已配置过扩展目录则PASS

#extension_dir 目录根据 sphinx 扩展安装成功后提示的目录
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20121212/"

2.配置文件里启用扩展
[sphinx]
extension=sphinx.so

3.重启php

原文地址:https://www.cnblogs.com/dongruiha/p/7458650.html