Board logo

标题: [求助] 能否给一个基于WDCP的安装Sphinx的教程? [打印本页]

作者: longyushen    时间: 2015-1-18 01:32     标题: 能否给一个基于WDCP的安装Sphinx的教程?

官方能否发布一个安装Sphinx的教程?在DZ要用到全文搜索,需要安装Sphinx,
在网上找的方法都用不了,希望官方能出一个在WDCP里面安装的教程。按照以下方法操作都不行
作者: longyushen    时间: 2015-1-18 01:33

本帖最后由 longyushen 于 2015-1-18 01:36 编辑

例如:
1. 安装软件
wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.13.tar.gz
tar zxvf coreseek-3.2.13.tar.gz
cd coreseek-3.2.13
cd mmseg-3.2.13
./bootstrap #这一步也许会出错,提示很多command not found , 解决办法: 安装 libtool centos 直接使用yum安装 : yum install -y libtool
./configure --prefix=/usr/local/mmseg
make && make install
cd csft-3.2.13
./configure --prefix=/usr/local/sphinx  --with-mysql=/www/wdlinux/mysql-5.1.63  --with-mmseg=/usr/local/mmseg/ --with-mmseg-includes=/usr/local/mmseg/include/mmseg/  --with-mmseg-libs=/usr/local/mmseg/lib/
make && make install
作者: longyushen    时间: 2015-1-18 01:35

2. 配置sphinx
vim /usr/local/sphinx/etc/csft.cnf # 内容如下

csft.cnf代码.zip (2.51 KB)
3. 首次生成索引
/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/csft.conf --all

4. 启动sphinx
/usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/csft.conf

5. 指定计划任务
* 0-3 * * * root /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/csft.conf posts_minute --rotate
* 6-23 * * * root /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/csft.conf posts_minute --rotate
0 4 * * * root /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/csft.conf posts_merge --rotate && /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/csft.conf --merge posts posts_merge --rotate

* 0-3 * * * root /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/csft.conf threads_minute --rotate
* 6-23 * * * root /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/csft.conf threads_minute --rotate
0 4 * * * root /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/csft.conf threads_merge --rotate && /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/csft.conf --merge threads threads_merge --rotate
复制代码

6. 设置discuz后台
使用创始人账号登陆discuz后台, 全局 -> 搜索设置 ->
开启sphinx
sphinx 主机名 localhost
端口: 3312
标题索引名: threads,threads_minute
全文索引名:posts,posts_minute
项目数:10000
模式:保持默认即可

7. 更改discuz代码
打开/source/module/search/forum.php
找到以下这行
if($srchtype == 'fulltext' && $_G['setting']['sphinxon']) {
改成
if($_G['setting']['sphinxon']) {
再找到下面几行(注意:仅在你discuz版本为gbk时才需要做 以下修改)
f($srchtype == "fulltext") {
$result = $s->query("'".$srchtxt."'", $_G['setting']['sphinxmsgindex']);
} else {
$result = $s->query($srchtxt, $_G['setting']['sphinxsubindex']);
}
改成
$_srchtxt = iconv('gbk','utf-8',$srchtxt); //将gbk转成 utf-8
if($srchtype == "fulltext") {
$result = $s->query("'".$_srchtxt."'", $_G['setting']['sphinxmsgindex']);
} else {
$result = $s->query($_srchtxt, $_G['setting']['sphinxsubindex']);
}

附件: csft.cnf代码.zip (2015-1-18 01:35, 2.51 KB) / 下载次数 15
http://wdlinux.cn/bbs/attachment.php?aid=4994&k=4d5c38de6f1f52ae2dd9402d8eb738cf&t=1714246219&sid=9Ky9b9
作者: longyushen    时间: 2015-1-20 14:05

顶上去,怎么没有人处理的呢?
作者: longyushen    时间: 2015-1-29 14:04

,.........
作者: longyushen    时间: 2015-1-30 10:54

。。。。。。
作者: longyushen    时间: 2015-1-31 02:04

。。。。。。。。。。。。。。。。。。。。。。。
作者: whale1011    时间: 2015-5-6 23:02

asdfasdfasdfasdfasdfasdf
作者: shanyingqing    时间: 2016-5-19 12:28

分词这块还是不错的




欢迎光临 WDlinux官方论坛 (http://wdlinux.cn/bbs/) Powered by Discuz! 7.2