centos配置安装sphinx

1. 下载Sphinx最新版  http://www.sphinxsea.../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

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
或/usr/bin/indexer  --config /var/sphinx/sphinx.conf --all

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

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 

你可能感兴趣的:(centos配置安装sphinx)