- _nosay
给php安装sphinx扩展全过程备忘
2017-08-23 15:50:54
一个小博客,上sphinx真的是简直了,但生命不息,折腾不止,开搞。
首先,上传官网最新的安装包,
到服务器,解压,解压过程略。
进入sphinx安装目录,执行
./configure --prefix=/usr/local/sphinx make make install
三步曲,在make的时候报错,
libsphinx.a(sphinx.o): In function `xmlUnknownEncoding(void*, char const*, XML_Encoding*)': /opt/sphinx/src/sphinx.cpp:29116: undefined reference to `libiconv_open' /opt/sphinx/src/sphinx.cpp:29134: undefined reference to `libiconv' /opt/sphinx/src/sphinx.cpp:29140: undefined reference to `libiconv_close' collect2: error: ld returned 1 exit status Makefile:326: recipe for target 'indexer' failed make[2]: *** [indexer] Error 1 make[2]: Leaving directory '/opt/sphinx/src' Makefile:244: recipe for target 'all' failed make[1]: *** [all] Error 2 make[1]: Leaving directory '/opt/sphinx/src' Makefile:331: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1
修改./src/MakeFile文件,找到这一行
LIBS = -lexpat -ldl -lm -lz -L/usr/local/lib -lrt -lpthread 替换为 LIBS = -lexpat -ldl -lm -lz -liconv -L/usr/local/lib -lrt -lpthread
然后测试编译安装通过。
接下来开始安装php7的sphinx扩展,下载地址
解压进入相应目录,执行
phpize ./configure --with-php-config=/usr/local/php/bin/php-config #其中php-config是笔者的路径 make make install
在./configure的时候报错
configure: error: Cannot find libsphinxclient headers
解决方法
回到原sphinx安装目录下的api/libsphinxclient 文件夹中,执行
./configure && make && make install
然后继续编译sphinx php拓展,实际测试通过。
最后打开php.ini 加入
extension=sphinx.so
至此,完成了php的sphinx拓展安装。