运维辞典@欢迎访问小站,如有疑问,可通过右侧QQ或底部邮箱联系,非常感谢@

linux系统php环境安装sphinx扩展及应用

PHP Administrator 532℃

1.下载所有程序包

~_~
sphinx程序包(新版本后面再测试):http://sphinxsearch.com/files/archive/sphinx-0.9.9.tar.gz
PHP扩展(已是当前最新版本):http://pecl.php.net/get/sphinx-1.3.3.tgz
备用下载地址
http://west.724001.com/abc/linuxweb/php/sphinx/sphinx-0.9.9.tar.gz
http://west.724001.com/abc/linuxweb/php/sphinx/sphinx-1.3.3.tgz

2.准备好基本的LAMP或者LNMP环境

~_~
LAMP环境一键部署https://www.724001.com/305.html
测试CentOS6.9
APACHE2.4.29
MYSQL5.6.38
PHP5.6.32
yum -y install gcc-c++

3.安装sphinx程序包

~_~
tar zxvf sphinx-0.9.9.tar.gz
cd sphinx-0.9.9
./configure –prefix=/usr/local/sphinx
make
##############出错1##############
make install

4.安装php扩展

~_~
tar -zxvf sphinx-1.3.3.tgz
cd sphinx-1.3.3
/usr/local/src/php-5.6.32/bin/phpize
./configure –with-php-config=/usr/local/src/php-5.6.32/bin/php-config –with-sphinx=/usr/local/sphinx/
##############出错2##############
make
make install
安装完成提示扩展文件存放在/usr/local/src/php-5.6.32/lib/php/extensions/no-debug-non-zts-20131226/下
修改php.ini,添加扩展
找到extension_dir位置添加
extension_dir=”/usr/local/src/php-5.6.32/lib/php/extensions/no-debug-non-zts-20131226/”
###extension_dir若之前安装过其他扩展,则忽略
extension=sphinx.so
保存退出后重启apache服务,访问phpinfo查看.

遇到的错误及解决方法:

~_~
1.make安装sphinx报错时如果报如下错误
../config/depcomp: line 512: exec: g++: not found
解决:yum -y install gcc-c++
2.php扩展配置时出错,如下,是没有安装libsphinxclient
checking for libsphinxclient headers in /usr/local/sphinx/… not found
configure: error: Cannot find libsphinxclient headers
解决:进入sphinx解压后的程序包/api/libsphinxclient目录
./configure –prefix=/usr/local/sphinx/
make
##############出错3##############
make install
3.安装libsphinxclient时如果报如下错误
sphinxclient.c:1216: error: static declaration of ‘sock_close’ follows non-static declaration
sphinxclient.c:280: note: previous declaration of ‘sock_close’ was here
请执行sed -ie ‘280s/^/static /’ sphinxclient.c

码字很辛苦,转载请注明来自:《运维辞典 » linux系统php环境安装sphinx扩展及应用

喜欢 (2)