你是不是暗恋我,那就给我发个消息呀,让我知道o(∩∩)o
分类: LINUX
2014-08-06 15:43:41
Sphinx 安装
wget
tar zxf sphinx-1.10-beta.tar.gz
cd sphinx-1.10-beta
./configure –prefix=/usr/local/sphinx –with-mysql
make && make install
libsphinxclient 安装(PHP模块需要)
cd api/libsphinxclient
./configure –prefix=/usr/local/sphinx
make 时会出现以下错误:
libsphinxclient # make make all-am make[1]: Entering directory `/work/setup/sphinx-1.10-beta/api/libsphinxclient' /bin/sh ./libtool --mode=compile --tag=CC gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c -o sphinxclient.lo sphinxclient.c mkdir .libs gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c sphinxclient.c -fPIC -DPIC -o .libs/sphinxclient.o sphinxclient.c: In function 'net_connect_get': sphinxclient.c:1358: error: 'SO_NOSIGPIPE' undeclared (first use in this function) sphinxclient.c:1358: error: (Each undeclared identifier is reported only once sphinxclient.c:1358: error: for each function it appears in.) make[1]: *** [sphinxclient.lo] Error 1 make[1]: Leaving directory `/work/setup/sphinx-1.10-beta/api/libsphinxclient' make: *** [all] Error 2
请打开sphinxclient.c,将以下代码:
#ifndef _WIN32 if ( setsockopt ( sock, SOL_SOCKET, SO_NOSIGPIPE, (void *)&optval, (sock len_t)sizeof(optval) ) < 0 ) { set_error ( client, "setsockopt() failed: %s", sock_error() ); return -1; } #endif
修改为:
#ifndef _WIN32 #ifdef SO_NOSIGPIPE if ( setsockopt ( sock, SOL_SOCKET, SO_NOSIGPIPE, (void *)&optval, (sock len_t)sizeof(optval) ) < 0 ) { set_error ( client, "setsockopt() failed: %s", sock_error() ); return -1; } #endif #endif
如果出现以下错误:
gcc -g -O2 -o test test.o .libs/libsphinxclient.a .libs/libsphinxclient.a(sphinxclient.o): In function `set_error': /opt/software/sphinx-1.10-beta/api/libsphinxclient/sphinxclient.c:359: undefined reference to `_vsnprintf' collect2: ld returned 1 exit status make[1]: *** [test] Error 1 make[1]: Leaving directory `/opt/software/sphinx-1.10-beta/api/libsphinxclient' make: *** [all] Error 2
则注释掉头部的:
#define vsnprintf _vsnprintf
就可以了。
接着:
make install
Sphinx Client PHP 模块安装
wget
tar zxf sphinx-1.1.0.tgz
cd sphinx-1.1.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/sphinx/
make && make install
更新:
Sphinx 2.0.1 版本的安装请看:
http://hily.me/blog/2011/05/sphinx-server-2-0-1-quick-installation/