2012-01-18 13 views
4

これはRajaです。私はWeb開発にPHPを使用しています。最近私はOSとしてLINUXを使って自分のアプリケーションに "Sphinx"検索をインストールすることになっていました。LINUX(ubuntu)にSphinxをインストールする方法

私はLINUX(Ubuntuの)OSにスフィンクスをインストールするには、このウェブサイトに

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

を与えられた指示に従ってきたと私は、端末内のアプリケーションをテストしてみた、私はこの

のような結果を得ました
[email protected]:/# 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 total 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, weight=2, group_id=1, 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 

問題は、私はsphinx.conf、sphinxapi.phpとtest.phpをファイルが含まれていた場所 "の/ var/www /のsphinx_search"、ディレクトリを作成した、ということです。

sphinx.confの背後にあるコードは

source 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 
{ 
    source = 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.phpを背後にあるコードは

require_once('sphinxapi.php'); 
//require_once('api/sphinxapi.php'); 
$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.)"} 

私はスフィンクスの新人だから、すぐにそれを手に入れます。誰でも私がさらに進歩を助けることができます。以前の解決策を探して

不思議なことに、事前に

おかげで、 ラジャ。

答えて

3

searchdデーモンを実行する必要のない検索ユーティリティを使用して検索した例では、そのため、検索は正常に実行されます。

のように、あなたはsearchdデーモンを起動する必要がありスフィンクスAPIを使用するには:ブラウザでアプリケーションを試すことができた後

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

:あなたはapt-getを試行し使用してスフィンクスをインストールした場合

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

。私はあなたがUbuntuの下スフィンクスを実行していると述べ、この

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

、いないWindows 7を理解していない

しかし、スフィンクスサーバーIPはlocalhostではなく、UbuntuのホストのIPでなければなりません。

BTW、ubuntu ship Sphinxの旧バージョンです。私はsphinxsearch.comから最新のものをダウンロードすることをお勧めします。最新版では、これはあなたのために働くかもしれないあなたのsphinx.confで2.0.3

+0

ご回答いただきありがとうございます.Linuxのsphinxインストールについてもう少し説明してください。私は混乱している。 LINUXで私は/ var/www /に自分のソースを維持しているので。どのパスに私はスフィンクスをインストールする必要があります。この部分で私は混乱しています。インストール方法とブラウザでアプリケーションを実行する方法について明確な説明があれば素晴らしいだろう。 – Raja

2
この1

$s->SetServer('localhost', 'mysql_user_name', 'mysql_password', 3312); 

に)(あなたは、SetServerを変更し、3312としてポートを設定

port = 3312 

Iのものです。もし何が起こったのか教えてください。

関連する問題