CentOS5.5 安装 Sphinx 全文检索

81 篇文章 0 订阅

1. 下载Sphinx最新版  http://www.sphinxsearch.com/downloads.html

2. 安装
# tar -zxvf sphinx-0.9.9.tar.gz
# cd sphinx-0.9.9/
#  ./configure --prefix=/usr/local/sphinx --with-mysql-includes=/usr/local/mysql/include/mysql/ --with-mysql-libs=/usr/local/mysql/lib/mysql --with-iconv
# make && make install

 

../depcomp: line 512: exec: g++: not found
make[2]: *** [my_new.o] 错误 127
make[2]: Leaving directory `/tmp/lamp/mysql-5.0.56/mysys'
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/tmp/lamp/mysql-5.0.56'
make: *** [all] 错误 2
[root@localhost mysql-5.0.56]#
 
解决办法:
yum install -y gcc-c++

3. 配置
# cd /usr/local/sphinx/etc
# cp sphinx-min.conf.dist joomla.conf
# vi joomla.conf


#
# Minimal Sphinx configuration sample (clean, simple, functional)
#

source joomla_src
{
         type                    = mysql

         sql_host                = localhost
         sql_user                = root
         sql_pass                = 123456
         sql_db                  = joomla
         sql_port                = 3306   # optional, default is 3306

         sql_query               = SELECT * FROM jos_content

         sql_attr_uint           = id
         sql_attr_timestamp      = created

         sql_query_info          = SELECT * FROM jos_content WHERE id=$id
}


index joomla_index
{
         source                  = joomla_src
         path                    = /usr/local/sphinx/var/data/joomla_index
         docinfo                 = extern
         charset_type            = utf-8
}


indexer
{
         mem_limit               = 32M
}


searchd
{
         port                    = 9312
         log                     = /usr/local/sphinx/var/log/searchd.log
         query_log               = /usr/local/sphinx/var/log/query.log
         read_timeout            = 5
         max_children            = 30
         pid_file                = /usr/local/sphinx/var/log/searchd.pid
         max_matches             = 1000
         seamless_rotate         = 1
         preopen_indexes         = 0
         unlink_old              = 1
}

保存退出

4. 建立索引
# /usr/local/sphinx/bin/indexer   --config joomla.conf   --all joomla_index

5. 启动sphinx后台服务
# /usr/local/sphinx/bin/searchd -c /usr/local/sphinx/etc/joomla.conf   -i joomla_index &

6. 测试
#/usr/local/php/bin/php-cgi test.php -h localhost -p 9312 -i joomla_index -ph title
X-Powered-By: PHP/5.2.10
Content-type: text/html

Query 'title ' retrieved 16 of 16 matches in 0.001 sec.
Query stats:
     'title' found 61 times in 16 documents

Matches:
1. doc_id=44, weight=2, created=1970-01-01 07:33:27
2. doc_id=1, weight=1, created=1970-01-01 07:33:28
3. doc_id=4, weight=1, created=1970-01-01 07:33:28
4. doc_id=5, weight=1, created=1970-01-01 07:33:28
5. doc_id=10, weight=1, created=1970-01-01 07:33:28
6. doc_id=11, weight=1, created=1970-01-01 07:33:28
7. doc_id=20, weight=1, created=1970-01-01 07:33:28
8. doc_id=21, weight=1, created=1970-01-01 07:33:28
9. doc_id=24, weight=1, created=1970-01-01 07:33:28
10. doc_id=25, weight=1, created=1970-01-01 07:33:28
11. doc_id=26, weight=1, created=1970-01-01 07:33:28
12. doc_id=27, weight=1, created=1970-01-01 07:33:28
13. doc_id=28, weight=1, created=1970-01-01 07:33:28
14. doc_id=30, weight=1, created=1970-01-01 07:33:28
15. doc_id=38, weight=1, created=1970-01-01 07:33:28
16. doc_id=45, weight=1, created=1970-01-01 07:33:27

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值