寶塔面板安裝的用戶,請把網站根目錄user.ini文件清空,否則無法跨站點引入全文檢索文件導致搜索失敗,全站掛掉
安裝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 安裝的默認路勁 /usr/local/xunsearch/ ,如果你不是很精通就不要改了,方便照著我下面的操作來做。
1.2 正常情況下5分鐘后安裝完成,如果失敗請看提示編譯到哪里出錯了,對應出錯的所需庫,進行安裝。
#如果發現有警告或者錯誤,對于響應的模塊進行安裝,如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 配置文件內容:
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文件直接可以下載壓縮包解壓拿出來即可:
question.ini和topic.ini配置文件.zip
將壓縮包下載上傳到 /usr/local/xunsearch/sdk/php/app/
/usr/local/xunsearch/data目錄新建一個question和topic文件夾,一定要手動創建好,否則網站接入必掛!
將xunsearch目錄下得data,sdk,tmp三個文件夾設置777,應用到子目錄(也可以自己命令操作 )
#上面都ok了,重啟一下服務,并把服務放入到開機啟動項
/usr/local/xunsearch/bin/xs-ctl.sh restart
檢查是否安裝成功:運行如下命令
cd /usr/local/xunsearch/sdk/php/util
php RequiredCheck.php
如圖所示
如果沒問題就會提示如下信息
警告可以忽略!
#重啟http服務
service httpd restart
#在問答系統后臺開始全文搜索功能
數據庫 my.cnf 加入 ft_min_word_len=1
注意:配置成功后data,sdk,tmp三個文件夾以及子目錄要777,不然權限不夠還是無法寫入網站直接掛了:
PHP-SDK文件全路徑 /usr/local/xunsearch/sdk/php/lib/XS.php
進入后臺系統設置--搜索設置里,開啟全文檢索,配置sdk地址,然后重建索引。
寶塔面板安裝的用戶,請把網站根目錄user.ini文件清空,否則無法跨站點引入全文檢索文件導致搜索失敗,全站掛掉
剛開始 /usr/local/xunsearch/data/目錄不會創建question和topic文件夾,等點擊如上圖重建索引后會生成,但是首次網站估計還是會奔潰,所以還要對/usr/local/xunsearch/data/question和/usr/local/xunsearch/data/topic兩個文件夾權限 777以及勾選子目錄應用全部,反正配置上不會那么順手,如果掛了就用下面得辦法恢復
如果網站掛了如何恢復,關閉全文檢索教程:
https://wenda.whatsns.com/article-14558.html
xunsearch 開機啟動設置方法
XunSearch在CentOS7.x環境下開機自啟動
話不多說,直接上代碼:
xs.sh內容如下
保存文件,繼續執行如下代碼,賦值權限
繼續執行,添加腳本到自啟動項目中
這邊開機自啟動就完成了。
如果xs.sh文件中,不加入chkconfig:2345 55 25這行,會報錯
TIP