Linux   发布时间:2022-03-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何在LINUX上安装Sphinx(ubuntu)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_450_1@

概述

这是Raja,我正在使用 php进行Web开发.最近我应该用LINUX作为操作系统将“Sphinx”搜索安装到我的应用程序中. 我遵循了本网站提供的指示 http://www.howtoforge.com/how-to-install-sphinx-on-ubuntu-10.10 在LINUX(Ubuntu)操作系统中安装sphinx并且我在终端中测试了应用程序,我得到了这样的结果 root@de
@H_944_10@
这是Raja,我正在使用 PHP进行Web开发.最近我应该用LINUX作为操作系统将“Sphinx搜索安装到我的应用程序中.

我遵循了本网站提供的指示

http://www.howtoforge.com/how-to-install-sphinx-on-ubuntu-10.10

在LINUX(Ubuntu)操作系统中安装sphinx并且我在终端中测试了应用程序,我得到了这样的结果

root@dev2:/# search "test"
Sphinx 0.9.9-release (r2117)
Copyright (C) 2001-2009,Andrew Aksyonoff

using config file '/etc/sphinxsearch/sphinx.conf'...
index 'test1': query 'test ': returned 3 matches of 3 @R_821_10586@l in 0.000 sec

displaying matches:
1. document=1,weight=2,group_id=1,date_added=Thu Jan  5 18:18:55 2012
        id=1
        group_id=1
        group_id2=5
        date_added=2012-01-05 18:18:55
        title=test one
        content=this is my test document number one. also checking search within phrases.
2. document=2,date_added=Thu Jan  5 18:18:55 2012
        id=2
        group_id=1
        group_id2=6
        date_added=2012-01-05 18:18:55
        title=test two
        content=this is my test document number two
3. document=4,weight=1,group_id=2,date_added=Thu Jan  5 18:18:55 2012
        id=4
        group_id=2
        group_id2=8
        date_added=2012-01-05 18:18:55
        title=doc number four
        content=this is to test groups

words:
1. 'test': 3 documents,5 hits

问题是,我在“/ var / www / sphinx_search”位置创建了目录,其中包含sphinx.conf,sphinxapi.@L_616_12@和test.@L_616_12@文件.

sphinx.conf背后的代码

@R_696_9016@e src1
{
    type = MysqL
    sql_host = localhost
    sql_user = user
    sql_pass = pwd
    sql_db = test
    sql_port = 3306 # optional,default is 3306
    sql_query = \
    SELECT id,group_id,UNIX_timestAMP(date_added) AS date_added,title,content \
    FROM documents
    sql_attr_uint = group_id
    sql_attr_timestamp = date_added
    sql_query_info = SELECT * FROM documents WHERE id=$id
}

index test1
{
    @R_696_9016@e = src1
    path = /var/lib/sphinxsearch/data/test1
    docinfo = extern
    charset_type = sbcs
}

indexer
{
    mem_limit = 32M
}

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

和test.@L_616_12@背后的代码

require_once('sphinxapi.@L_616_12@');
//require_once('api/sphinxapi.@L_616_12@');
$s = new SphinxClient;
$s->setServer("123.123.123.123",9312); // NOT "localhost" under Windows 7!
$s->setMatchMode(SPH_MATCH_EXTENDED2);

$result = $s->Query("group");

echo '<pre>';print_r($result);

我试图在浏览器中运行此应用程序(http:// localhost / Raja / search_ENGIne / sphinx /)时,会显示错误.

{"status":"Failed","status_message":"connection to localhost:9312 Failed (errno=10060,msg=A connection attempt Failed because the connected party did not properly respond after a period of time,or established connection Failed because connected host has Failed to respond.)"}

由于我是狮身人面像的新手,我无法马上得到它.任何人都可以帮助我继续前进.

奇怪地寻找解决方案,

提前致谢,
拉贾.

解决方法

在您的搜索示例中,您使用搜索实用程序不需要运行searchd守护程序.这就是搜索成功执行的原因.

要使用sphinx API,您需要启动searchd守护程序,例如:

/path/to/searchd --config /etc/sphinxsearch/sphinx.conf

如果您使用apt-get安装了sphinx,请尝试:

searchd --config /etc/sphinxsearch/sphinx.conf

之后,您可以在浏览器中尝试应用程序.

但是,我不明白这一点

$s->setServer("123.123.123.123",9312); // NOT "localhost" under Windows 7!

你说你在ubuntu下运行sphinx,而不是windows 7.因此,sphinx服务器IP应该是ubuntu主机的IP,而不是localhost.

BTW,ubuntu发布旧版Sphinx,我建议从sphinxsearch.com下载最新版本.最新版本是2.0.3

大佬总结

以上是大佬教程为你收集整理的如何在LINUX上安装Sphinx(ubuntu)全部内容,希望文章能够帮你解决如何在LINUX上安装Sphinx(ubuntu)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。