PHP7 安装 Sphinx 有坑

  1. php的sphinx扩展安装依赖libsphinxclient,该依赖安装在服务端安装程序中有,下载地址在这里,可以根据对应环境下载,我在这里下载的是3.0.3的Linux x64 binaries。
  2. 下载后解压,cd sphinx-3.0.3/api/libsphinxclient/进入依赖安装目录
    ./configure --prefix=/usr/local/sphinxclient
    make
    make install
    安装完成
    3、从php官网下载sphinx客户端地址
    解压进入目录
    /usr/local/bin/phpize
    ./configure --with-php-config=/usr/local/bin/php-config --with-sphinx=/usr/local/sphinxclient
    make
    安装报错
    参考内容
    找了好久原因最后才确定是sphinx对应php版本问题,到这里下载php7版本的sphinx扩展,刚开始下载的是tar.gz文件,可以在虚拟机里使用tar zxvf 一直解压不了,无奈只能下载zip包,安装unzip来解压文件,最后
    /usr/local/bin/phpize
    ./configure --with-php-config=/usr/local/bin/php-config --with-sphinx=/usr/local/sphinxclient
    make
    make install终于安装成功,有点小激动。

此次安装花费了不少时间,主要是百度找不到相关问题,初步猜测是版本问题,但是找到php7对应的版本后下载gz文件解压不了,有点小灰心,最后直接复制错误到google 找一下,真的能找到相关的问题,至少确认是php7的版本的问题,最后无奈下了zip包来尝试才成功,坑。貌似php7的sphinx扩展还没有发布,目录是dev开发版本,接下来会跑小demo.

雪花飘
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
讨论数量: 1
幽弥狂

根据你写的我还是装不上。。

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_CONST(SPH_RANK_BM25);
  ^
Makefile:194: recipe for target 'sphinx.lo' failed
make: *** [sphinx.lo] Error 1
5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!