Chinaunix首页 | 论坛 | 博客
  • 博客访问: 146916
  • 博文数量: 123
  • 博客积分: 5770
  • 博客等级: 大校
  • 技术积分: 1240
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-12 16:31
个人简介

闲情逸致 http://EZ38.com

文章分类

全部博文(123)

文章存档

2014年(1)

2010年(122)

我的朋友
最近访客

分类: LINUX

2010-02-21 15:16:59

安装Sphinx 搜索引擎(google)
 
Installing Sphinx on Linux
  1. Extract everything from the distribution tarball (haven't you already?) and go to the sphinx subdirectory:
     
    $ tar xzvf sphinx-0.9.8.tar.gz
    $ cd sphinx
     
  2. Run the configuration program:
     
    $ ./configure
 Error 不能找到mysql-devel,需要手工安装mysql-devel包
./configure  --with-mysql
yum --list |grep mysql-devel
yum install mysql-devel.i586
3.There's a number of options to configure. The complete listing may be obtained by using --help switch. The most important ones are:
--prefix, which specifies where to install Sphinx; such as --prefix=/usr/local/sphinx (all of the examples use this prefix)
 
--with-mysql, which specifies where to look for MySQL include and library files, if auto-detection fails;
--with-pgsql, which specifies where to look for PostgreSQL include and library files.
 
Build the binaries:
 
$ make
 
Install the binaries in the directory of your choice: (defaults to /usr/local/bin/ on *nix systems, but is overridden with configure --prefix)
 
 
$ make install
 
 $ cd /usr/local/sphinx/etc
      | $ cp sphinx.conf.dist sphinx.conf
      | $ vi sphinx.conf
 
  | $ mysql -u test < /usr/local/sphinx/etc/example.sql
   2. Run the indexer to create full-text index from your data:
      | $ cd /usr/local/sphinx/etc
      | $ /usr/local/sphinx/bin/indexer

 

Quick Sphinx usage tour

All the example commands below assume that you installed Sphinx in /usr/local/sphinx, so searchd can be found in /usr/local/sphinx/bin/searchd.

To use Sphinx, you will need to:

  1. Create a configuration file.

    Default configuration file name is sphinx.conf. All Sphinx programs look for this file in current working directory by default.

    Sample configuration file, sphinx.conf.dist, which has all the options documented, is created by configure. Copy and edit that sample file to make your own configuration: (assuming Sphinx is installed into /usr/local/sphinx/)

    $ cd /usr/local/sphinx/etc
    $ cp sphinx.conf.dist sphinx.conf
    $ vi sphinx.conf

    Sample configuration file is setup to index documents table from MySQL database test; so there's example.sql sample data file to populate that table with a few documents for testing purposes:

    $ mysql -u test < /usr/local/sphinx/etc/example.sql

  2. Run the indexer to create full-text index from your data:

    $ cd /usr/local/sphinx/etc
    $ /usr/local/sphinx/bin/indexer

  3. Query your newly created index!

To query the index from command line, use search utility:

$ cd /usr/local/sphinx/etc
$ /usr/local/sphinx/bin/search test

To query the index from your PHP scripts, you need to:

  1. Run the search daemon which your script will talk to:

    $ cd /usr/local/sphinx/etc
    $ /usr/local/sphinx/bin/searchd

  2. Run the attached PHP API test script (to ensure that the daemon was succesfully started and is ready to serve the queries):

    $ cd sphinx/api
    $ php test.php test

  3. Include the API (it's located in api/sphinxapi.php) into your own scripts and use it.

Happy searching!



 

阅读(368) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~