liunx安装编译sphinx&coreseek

安装版本 : sphinx-0.9.9.tar.gz 客户端
                    sphinx-1.1.0.tgz php模块
解压软件包 tar zxvf sphinx-0.9.9.tar.gz
进入文件夹 cd sphinx-0.9.9
配置文件  ./configure --prefix=/usr/local/sphinx --with-mysql=/usr/local/mysql/
编译 make && make install
进入文件夹cd /usr/local/sphinx/
文件结构 tree
.
|-- bin
| |-- indexer
| |-- indextool
| |-- search
| |-- searchd
| `-- spelldump
|-- etc
| |-- example.sql
| |-- sphinx-min.conf.dist
| `-- sphinx.conf.dist
`-- var
    |-- data ----存储索引
    `-- log
 
创建配置文件
[root@localhost etc]# ls
example.sql sphinx.conf.dist sphinx-min.conf.dist
[root@localhost etc]# cp sphinx.conf.dist sphinx.conf //复制配置文件
[root@localhost etc]# ls
example.sql sphinx.conf sphinx.conf.dist sphinx-min.conf.dist
配置配置文件
第一块:
主数据源
13行 sourc 改为 source main 修改主数据源名字
24-28行 修改数据库名密码及数据库
35行 开启 sql_sock
73行  开启sql_query_pre = SET NAMES utf8  74 sql_query_pre = SET SESSION query_cache_type=OFF
79行 更改搜索语句  sql_query =select user_id,username,truename,pwd,s ex,addr,code,pho,email,zt,ztime,age,tou,gip FROM cq_user(表)
109行 注释 #sql_attr_uint = group_id
131行 注释  #sql_attr_timestamp = date_added
187 返回结果语句 $id 索引表的主键id      sql_query_info = SELECT * FROM documents (表名)WHERE id(id字段)=$id
第二块:
增量数据源
256行 注释 #source src1throttled : src1
#{
# sql_ranged_throttle = 100
#}
第三块:
主数据索引
271行- index main
更改为mian      source = main
     path = /usr/local/sphinx/var/data/main
340行 设置字符集 charset_type = sbcs
353行打开 charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F , U+430..U+44F
第四块:
增量数据索引 inherited index example
第五块:
分布式索引distributed  注释
第六块:
索引器配置
第七块:
serachd

创建索引表
[root@localhost bin]# ./indexer
./indexer: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory
[root@localhost bin]#报错 yum安装版本才会存在 该文件夹中  复制到该文件夹
 [root@localhost bin]# cp /usr/local/mysql/lib/mysql/libmysqlclient.so.16 /usr/lib
Options are:
--config read configuration from specified file
                        (default is sphinx.conf) 如果不是sphinx 可通过 --config文件名 读配置文件
--all reindex all configured indexes 对所有文件创建索引表 (main 之前配置的)
[root@localhost bin]# ./indexer --all
Sphinx 0.9.9-release (r2117)
Copyright (c) 2001-2009, Andrew Aksyonoff
 
using config file '/usr/local/sphinx/etc/sphinx.conf'...
indexing index 'main'... 正在创建文件
collected 3 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 3 docs, 179 bytes
total 0.019 sec, 9072 bytes/sec, 152.05 docs/sec
total 1 reads, 0.000 sec, 0.2 kb/call avg, 0.8 msec/call avg
total 5 writes, 0.000 sec, 0.2 kb/call avg, 0.1 msec/call avg
创建索引表
 ./search test 搜索
using config file '/usr/local/sphinx/etc/sphinx.conf'...
index 'main': query 'test ': returned 1 matches of 1 total in 0.000 sec
displaying matches:
1. document=38, weight=3
        user_id=38
…… ……
words: 1. 'com': 3 documents, 3 hits

解压php扩展
[root@localhost lamp]# tar zxvf sphinx-1.1.0.tgz
package.xml
sphinx-1.1.0/CREDITS
sphinx-1.1.0/config.m4
sphinx-1.1.0/config.w32
sphinx-1.1.0/sphinx.c
sphinx-1.1.0/php_sphinx.h
[root@localhost lamp]# cd sphinx-1.1.0
[root@localhost sphinx-1.1.0]# ls
config.m4 config.w32 CREDITS php_sphinx.h sphinx.c
使用php命令
[root@localhost sphinx-1.1.0]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
[root@localhost sphinx-1.1.0]# ls
acinclude.m4 config.guess configure install-sh mkinstalldirs
aclocal.m4 config.h.in configure.in ltmain.sh php_sphinx.h
autom4te.cache config.m4 config.w32 Makefile.global run-tests.php
build config.sub CREDITS missing sphinx.c
配置config文件
 ./configure --with-php-config=/usr/local/php/bin/php-config
报错
configure: WARNING: You will need re2c 0.12.0 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for sphinx support... yes, shared
checking for libsphinxclient headers in default path... not found
configure: error: Cannot find libsphinxclient headers
进入[root@localhost sphinx-1.1.0]# cd ../sphinx-0.9.9
[root@localhost sphinx-0.9.9]# cd api/
[root@localhost api]# ls
java libsphinxclient ruby sphinxapi.php sphinxapi.py test2.php test2.py test.php test.py
(可以加载类文件api)
[root@localhost api]# cd libsphinxclient/
[root@localhost libsphinxclient]# ls
buildconf.sh configure libsphinxclient.vcproj missing sphinxclient.h
build.mk configure.in ltmain.sh README test.c
config.guess COPYING Makefile.am sphinxclient.c test.sln
config.sub install-sh Makefile.in sphinxclient_config.h.in test.vcproj
编译[root@localhost libsphinxclient]# ./configure
[root@localhost libsphinxclient]# make
sphinxclient.c:1217: error: static declaration of 'sock_close' follows non-static declaration
sphinxclient.c:280: error: previous declaration of 'sock_close' was here
make[1]: *** [sphinxclient.lo] Error 1
make[1]: Leaving directory `/lamp/sphinx-0.9.9/api/libsphinxclient'
make: *** [all] Error 2 报错
[root@localhost libsphinxclient]# vi sphinxclient.c
删除 static void sock_close ( int sock ) 中 【static 】
重新编译
[root@localhost libsphinxclient]# ./configure
[root@localhost libsphinxclient]# make && make install
返回
[root@localhost sphinx-1.1.0]# cd /lamp/sphinx-1.1.0
[root@localhost sphinx-1.1.0]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@localhost  ]# make && make install
进入查看 【类似 ini中的dell】
[root@localhost sphinx-1.1.0]# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
[root@localhost no-debug-non-zts-20060613]# vi /usr/local/php/etc/php.ini
添加
extension=sphinx.so
[root@localhost no-debug-non-zts-20060613]# /usr/local/apache2/bin/apachectl restart
重启apache