PHP7 安装 Sphinx

php 的 sphinx 扩展安装依赖 libsphinxclient,该依赖安装在服务端安装程序中有,下载下载地址在这里,可以根据对应环境下载,我在这里下载的是 3.0.3 的 Linux x64 binaries。
sphinx-3.0.3-facc3fb-linux-amd64-glibc2.12.tar.gz
tar -zxvf sphinx-3.0.3-facc3fb-linux-amd64-glibc2.12.tar.gz
下载后解压,cd sphinx-3.0.3/api/libsphinxclient/ 进入依赖安装目录
./configure --prefix=/usr/local/sphinxclient
make
make install
安装完成
3、从 php 官网下载 sphinx 客户端地址 下载
sphinx-d958afb.tar.gz
cd sphinx-d958afb 解压进入目录
/usr/local/php70/bin/phpize
./configure --with-php-config=/usr/local/php70/bin/php-config --with-sphinx=/usr/local/sphinxclient
make
安装报错
In file included from /usr/include/php/20160303/main/php.h:414:0,
from /home/download/sphinx-339e123/sphinx.c:24:
/home/download/sphinx-339e123/sphinx.c: In function ‘zm_startup_sphinx’:
/home/download/sphinx-339e123/sphinx.c:1940:15: error: ‘SPH_RANK_PROXIMITY_BM25’ undeclared (first use in this function)
SPHINX_CONST(SPH_RANK_PROXIMITY_BM25);
^
/usr/include/php/20160303/Zend/zend_constants.h:42:105: note: in definition of macro ‘REGISTER_LONG_CONSTANT’
#define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_nu
^
/home/download/sphinx-339e123/sphinx.c:1940:2: note: in expansion of macro ‘SPHINX_CONST’
SPHINX_CONST(SPH_RANK_PROXIMITY_BM25);
^
/home/download/sphinx-339e123/sphinx.c:1940:15: note: each undeclared identifier is reported only once for each function it appears in
SPHINX_CONST(SPH_RANK_PROXIMITY_BM25);
^
/usr/include/php/20160303/Zend/zend_constants.h:42:105: note: in definition of macro ‘REGISTER_LONG_CONSTANT’
#define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_nu
^
/home/download/sphinx-339e123/sphinx.c:1940:2: note: in expansion of macro ‘SPHINX_CONST’
SPHINX_CONST(SPH_RANK_PROXIMITY_BM25);
^
/home/download/sphinx-339e123/sphinx.c:1941:15: error: ‘SPH_RANK_BM25’ undeclared (first use in this function)
SPHINX_CONST(SPH_RANK_BM25);
^
/usr/include/php/20160303/Zend/zend_constants.h:42:105: note: in definition of macro ‘REGISTER_LONG_CONSTANT’
#define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_nu
^
/home/download/sphinx-339e123/sphinx.c:1941:2: note: in expansion of macro ‘SPHINX_CONST’
解决方案:
删除 sphinx.c里的SPH_RANK_PROXIMITY_BM25的报错函数重新编译成功。

/usr/local/bin/phpize
./configure --with-php-config=/usr/local/php70/bin/php-config --with-sphinx=/usr/local/sphinxclient
make && make install
到此成功完成php7 sphinx扩展的安装。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值