資源簡介
M('search')->add(array('title'=>$search_title,'add_time'=>date('Y-m-d H:i:s')));
if(is_numeric($search_title))
{
$search_title=(int)$search_title;
}
$arr_title=preg_split('/(?<!^)(?!$)/u', $search_title);
if(!empty($arr_title)) {
foreach($arr_title as $k=>$v) {
if(empty($v) or $v==' ') unset($arr_title[$k]); }
} $search_title=str_replace(' ','|',$search_title);
$search_title=$search_title.'|'.join('|',$arr_title);
include(ROOT.'common/sphinxapi.php');
$cl = new SphinxClient();
$cl->SetServer('127.0.0.1', 9312); //注意這里的主機
$cl->SetMatchMode(SPH_MATCH_ANY);
$cl->SetArrayResult(true); // $cl->SetSortMode("SPH_SORT_ATTR_DESC", 'id');
$cl->SetSortMode('SPH_SORT_RELEVANCE','title');
$cl->SetLimits(0, 5000, 10000);
$res = $cl->Query($search_title,'*');
$err = $cl->GetLastError();
3.解壓 tar zxvf sphinx-2.3.2-beta.tar.gz 4.安裝 ./configure --prefix=/www/server/sphinx --with-mysql=/www/server/mysql 第一個是你要安裝sphinx在什么地方,第二個中MySQL的路徑,你按實際配置修改 安裝一定到解壓后的目錄下安裝233 5.編譯 make make install 如果出錯 sphinx編譯安裝出錯:undefined reference to libiconv make[2]: *** [sphinx.o] Error 1 make[2]: Leaving directory `/www/sphinx-2.3.2-beta/src' make[1]: *** [all] Error 2 make[1]: Leaving directory `/www/sphinx-2.3.2-beta/src' make: *** [all-recursive] Error 1 解決辦法:打開configure文件,找到“#define USE_LIBICONV 1”,將注釋去掉,并將1改成0。 重新編譯 打開sphinx目錄 如果編譯成功 則會生成對應的目錄。 修改MySQL配置 要開啟mysql的緩存,在mysql配置文件 /etc/my.cnf; 添加以下內容 query_cache_size = 268435456 query_cache_type = 1 query_cache_limit = 1048576 # service mysqld restart #重啟mysql 修改配置文件 重啟 bin/下 生成主索引:./indexer --all --rotate [root@s4 bin]# ./indexer --all --rotate Sphinx 2.3.2-id64-beta (4409612) Copyright (c) 2001-2016, Andrew Aksyonoff Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) using config file '/www/server/sphinx/etc/sphinx.conf'... indexing index 'main'... WARNING: Attribute count is 0: switching to none docinfo collected 136 docs, 0.0 MB sorted 0.0 Mhits, 100.0% done total 136 docs, 13615 bytes total 0.089 sec, 151880 bytes/sec, 1517.12 docs/sec skipping non-plain index 'rt'... total 3 reads, 0.000 sec, 19.4 kb/call avg, 0.0 msec/call avg total 9 writes, 0.000 sec, 5.5 kb/call avg, 0.0 msec/call avg WARNING: failed to scanf pid from pid_file '/www/server/sphinx/var/log/searchd.pid'. WARNING: indices NOT rotated.
代碼片段和文件信息
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????142823??2018-09-11?15:45??sphinx2.3.2配置?超詳細\apache_222.png
?????文件??????108637??2018-09-11?15:35??sphinx2.3.2配置?超詳細\nginx.png
?????文件??????242422??2018-09-11?15:36??sphinx2.3.2配置?超詳細\phpstudy.png
?????文件????????3841??2020-04-03?16:47??sphinx2.3.2配置?超詳細\sphinx2.3.2(centos配置詳情).txt
?????文件???????54093??2018-05-07?17:17??sphinx2.3.2配置?超詳細\sphinxapi.php
?????目錄???????????0??2020-04-03?16:49??sphinx2.3.2配置?超詳細\
-----------?---------??----------?-----??----
?????文件??????142823??2018-09-11?15:45??sphinx2.3.2配置?超詳細\apache_222.png
?????文件??????108637??2018-09-11?15:35??sphinx2.3.2配置?超詳細\nginx.png
?????文件??????242422??2018-09-11?15:36??sphinx2.3.2配置?超詳細\phpstudy.png
?????文件????????3841??2020-04-03?16:47??sphinx2.3.2配置?超詳細\sphinx2.3.2(centos配置詳情).txt
?????文件???????54093??2018-05-07?17:17??sphinx2.3.2配置?超詳細\sphinxapi.php
?????目錄???????????0??2020-04-03?16:49??sphinx2.3.2配置?超詳細\
評論
共有 條評論