免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1550 | 回复: 0
打印 上一主题 下一主题

安装Sphinx 搜索引擎(google) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-02-21 15:16 |只看该作者 |倒序浏览
安装Sphinx 搜索引擎(google)

Installing Sphinx on Linux

  • 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


  • 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
       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:

  • 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

  • Run the indexer to create full-text index from your data:
    $ cd /usr/local/sphinx/etc
    $ /usr/local/sphinx/bin/indexer

  • 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:

  • Run the search daemon which your script will talk to:
    $ cd /usr/local/sphinx/etc
    $ /usr/local/sphinx/bin/searchd


  • 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


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



    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/111851/showart_2183334.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP