全文檢索xunsearch-問(wèn)題和文章模塊配置

寶塔面板安裝的用戶,請(qǐng)把網(wǎng)站根目錄user.ini文件清空,否則無(wú)法跨站點(diǎn)引入全文檢索文件導(dǎo)致搜索失敗,全站掛掉

  1. 安裝xunserch

#下載和安裝(安裝需要gcc gcc-c++ make支持,記得事先安裝)

wget http://www.xunsearch.com/download/xunsearch-full-latest.tar.bz2

tar -xjf xunsearch-full-latest.tar.bz2

cd xunsearch-full-1.4.15/

sh setup.sh

1.1 安裝的默認(rèn)路勁 /usr/local/xunsearch/  ,如果你不是很精通就不要改了,方便照著我下面的操作來(lái)做。

1.2 正常情況下5分鐘后安裝完成,如果失敗請(qǐng)看提示編譯到哪里出錯(cuò)了,對(duì)應(yīng)出錯(cuò)的所需庫(kù),進(jìn)行安裝。

#如果發(fā)現(xiàn)有警告或者錯(cuò)誤,對(duì)于響應(yīng)的模塊進(jìn)行安裝,如apc模塊。(centos 安裝命令就是 yum install php-pecl-apc)

#以下是question.ini文件,放入到/usr/local/xunsearch/sdk/php/app/ 下

project.name = question
project.default_charset = utf-8
server.index = 8383
server.search = 8384

[id]
type = id

[cid]
type = numeric

[cid1]
type = numeric

[cid2]
type = numeric

[cid3]
type = numeric

[author]

[authorid]
type = numeric

[answers]
type = numeric

[attentions]
type = numeric

[price]
type = numeric

[shangjin]
type = numeric

[status]
type = numeric

[views]
type = numeric

[time]
type = numeric

[title]
type = title

[description]
type = body

topic.ini 配置文件內(nèi)容:

project.name = topic
project.default_charset = utf-8
server.index = 8383
server.search = 8384

[id]
type = id

[articleclassid]
type = numeric

[image]

[author]

[authorid]
type = numeric

[views]
type = numeric

[readmode]
type = numeric

[freeconent]
type = string

[price]
type = numeric
[articleclassid]
type = numeric
[articles]
type = numeric

[likes]
type = numeric

[viewtime]
type = numeric

[title]
type = title

[describtion]
type = body

question.ini和topic.ini文件直接可以下載壓縮包解壓拿出來(lái)即可:

question.ini和topic.ini配置文件.zip

將壓縮包下載上傳到 /usr/local/xunsearch/sdk/php/app/

/usr/local/xunsearch/data目錄新建一個(gè)question和topic文件夾,一定要手動(dòng)創(chuàng)建好,否則網(wǎng)站接入必掛!

image.png

將xunsearch目錄下得data,sdk,tmp三個(gè)文件夾設(shè)置777,應(yīng)用到子目錄(也可以自己命令操作 )



#上面都o(jì)k了,重啟一下服務(wù),并把服務(wù)放入到開(kāi)機(jī)啟動(dòng)項(xiàng)

/usr/local/xunsearch/bin/xs-ctl.sh restart

檢查是否安裝成功:運(yùn)行如下命令

cd /usr/local/xunsearch/sdk/php/util

php RequiredCheck.php

如圖所示

如果沒(méi)問(wèn)題就會(huì)提示如下信息

警告可以忽略!


#重啟http服務(wù) 

service httpd restart

#在問(wèn)答系統(tǒng)后臺(tái)開(kāi)始全文搜索功能

數(shù)據(jù)庫(kù) my.cnf 加入 ft_min_word_len=1


注意:配置成功后data,sdk,tmp三個(gè)文件夾以及子目錄要777,不然權(quán)限不夠還是無(wú)法寫入網(wǎng)站直接掛了:






PHP-SDK文件全路徑 /usr/local/xunsearch/sdk/php/lib/XS.php



進(jìn)入后臺(tái)系統(tǒng)設(shè)置--搜索設(shè)置里,開(kāi)啟全文檢索,配置sdk地址,然后重建索引。

寶塔面板安裝的用戶,請(qǐng)把網(wǎng)站根目錄user.ini文件清空,否則無(wú)法跨站點(diǎn)引入全文檢索文件導(dǎo)致搜索失敗,全站掛掉

剛開(kāi)始 /usr/local/xunsearch/data/目錄不會(huì)創(chuàng)建question和topic文件夾,等點(diǎn)擊如上圖重建索引后會(huì)生成,但是首次網(wǎng)站估計(jì)還是會(huì)奔潰,所以還要對(duì)/usr/local/xunsearch/data/question和/usr/local/xunsearch/data/topic兩個(gè)文件夾權(quán)限 777以及勾選子目錄應(yīng)用全部,反正配置上不會(huì)那么順手,如果掛了就用下面得辦法恢復(fù)

如果網(wǎng)站掛了如何恢復(fù),關(guān)閉全文檢索教程:

https://wenda.whatsns.com/article-14558.html


xunsearch 開(kāi)機(jī)啟動(dòng)設(shè)置方法


XunSearch在CentOS7.x環(huán)境下開(kāi)機(jī)自啟動(dòng)

話不多說(shuō),直接上代碼:

cd /etc/rc.d/init.d/
vi xs.sh

xs.sh內(nèi)容如下

#!/bin/sh
#chkconfig: 2345 55 25
/usr/local/xunsearch/bin/xs-ctl.sh restart

保存文件,繼續(xù)執(zhí)行如下代碼,賦值權(quán)限

chmod +x  /etc/rc.d/init.d/xs.sh

繼續(xù)執(zhí)行,添加腳本到自啟動(dòng)項(xiàng)目中

cd /etc/rc.d/init.d
chkconfig --add xs.sh
chkconfig xs.sh on

這邊開(kāi)機(jī)自啟動(dòng)就完成了。

如果xs.sh文件中,不加入chkconfig:2345 55 25這行,會(huì)報(bào)錯(cuò)

service xs.sh does not support chkconfig

TIP

其中2345是默認(rèn)啟動(dòng)級(jí)別,級(jí)別有0-6共7個(gè)級(jí)別。

  等級(jí)0表示:表示關(guān)機(jī)   

  等級(jí)1表示:?jiǎn)斡脩裟J?  

  等級(jí)2表示:無(wú)網(wǎng)絡(luò)連接的多用戶命令行模式   

  等級(jí)3表示:有網(wǎng)絡(luò)連接的多用戶命令行模式   

  等級(jí)4表示:不可用   

  等級(jí)5表示:帶圖形界面的多用戶模式   

  等級(jí)6表示:重新啟動(dòng)

10是啟動(dòng)優(yōu)先級(jí),90是停止優(yōu)先級(jí),優(yōu)先級(jí)范圍是0-100,數(shù)字越大,優(yōu)先級(jí)越低。