久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

您的位置:首頁技術(shù)文章
文章詳情頁

Linux下編譯安裝Sphinx、中文分詞coreseek及PHP的sphinx擴(kuò)展

瀏覽:26日期:2022-09-14 11:15:08

Linux環(huán)境為:CentOS5.5、Ubuntu12.04

1、軟件下載

sphinx-2.1.3

coreseek-4.1

2、安裝 sphinx

tar zxvf sphinx-2.1.3.tar.gz //解壓sphinx包c(diǎn)d sphinx-2.1.3./configure --prefix=/usr/local/sphinx --with-mysql=/usr/local/mysql/

--prefix:指定 sphinx 的安裝路徑--with-mysql:指定 mysql 安裝路徑

sudo make && make install

編譯并安裝

安裝成功之后,sphinx 會(huì)形成三個(gè)命令:

indexer 創(chuàng)建索引命令searchd 啟動(dòng)進(jìn)程命令search 命令行搜索命令

注:上述命令默認(rèn)在/usr/local/sphinx/bin目錄下

3、配置 sphinx及使用

cd /usr/local/sphinx/etc

進(jìn)入 sphinx 的 etc 目錄下

sudo cp sphinx.conf.dist sphinx.conf

拷貝一份配置文件,并且命名為 sphinx.conf。

將該目錄下的example.sql文件導(dǎo)入本地?cái)?shù)據(jù)庫名為test的數(shù)據(jù)庫中。

修改配置信息,將其中數(shù)據(jù)庫連接信息修改為你的本地?cái)?shù)據(jù)庫信息。

然后使用如下命令導(dǎo)入數(shù)據(jù)并生成索引:

$ cd /usr/local/sphinx/etc$ sudo /usr/local/sphinx/bin/indexer --all

如果執(zhí)行indexer命令報(bào)錯(cuò):

ERROR: index ’test1stemmed’: sql_connect: Can’t connect to local MySQL server through socket ’/var/run/mysqld/mysqld.sock’

則可能是因?yàn)閙ysql.sock的位置問題,在本機(jī)中,改位置是/tmp/mysql.sock(與安裝mysql時(shí)設(shè)置有關(guān)),在sphinx.conf中取消這一行的注釋即可(去掉前面的#號(hào)):

#sql_sock ? ? ? ? ? ? ? ?= /tmp/mysql.sock

再次執(zhí)行上述indexer命令,一切正常。

執(zhí)行查詢的話可以使用如下指令:

$ cd /usr/local/sphinx/etc$ sudo /usr/local/sphinx/bin/search test

在執(zhí)行search搜索過程中可能報(bào)錯(cuò):

index ’test1’: search error: query too complex, not enough stack (thread_stack=-2665032K or higher required).

我試著在sphinx.conf中的searchd模塊中修改thread_stack的值,但沒有解決問題,后來注釋掉source src1中的如下這行

#sql_query_info ? ? ? ? = SELECT * FROM documents WHERE id=$id

再執(zhí)行search命令,就OK了。

后臺(tái)啟動(dòng)sphinx使用如下指令:

$ cd /usr/local/sphinx/etc$ sudo /usr/local/sphinx/bin/searchd

使用php腳本執(zhí)行搜素命令,可使用如下指令:

$ cd sphinx/api$ php test.php test

輸入結(jié)果如下:

Query ’test ’ retrieved 3 of 3 matches in 0.022 sec.Query stats:’test’ found 10 times in 6 documentsMatches:1. doc_id=1, weight=101, group_id=1, date_added=2014-01-20 10:07:372. doc_id=2, weight=101, group_id=1, date_added=2014-01-20 10:07:373. doc_id=4, weight=1, group_id=2, date_added=2014-01-20 10:07:374、安裝 coreseek

tar zxvf coreseek-4.1.tar.gz

解壓會(huì)出現(xiàn)兩個(gè)目錄:csft-4.1、mmseg-3.2.14

先安裝 mmseg

cd mmseg-3.2.14/./configure --prefix=/usr/local/mmseg

編譯如果出現(xiàn)錯(cuò)誤:“config.status: error: cannot find input file: src/Makefile.in”

解決方案:

sudo apt-get install automakeaclocallibtoolize --force 我運(yùn)行后有一個(gè)錯(cuò)誤,沒管它。automake --add-missingautoconfautoheadermake clean./configure --prefix=/usr/local/mmsegmakesudo make install

安裝 csft(coreseek)

cd csft-4.1/sh buildconf.sh./configure --prefix=/usr/local/coreseek --with-mysql=/usr/local/mysql/ --with-mmseg=/usr/local/mmseg/ --with-mmseg-includes=/usr/local/mmseg/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg/lib/ sudo make && make install

安裝完成之后和sphinx安裝后一樣,需要導(dǎo)入coreseek/etc/example.sql文件到本地?cái)?shù)據(jù)庫,然后拷貝sphinx.conf.dist到csft.conf,修改其中數(shù)據(jù)庫用戶名及密碼,測(cè)試出錯(cuò)和sphinx中出錯(cuò)解決辦法一樣。

使用 sphinx 需要做以下幾件事

1.有數(shù)據(jù);

2.建立 sphinx 配置文件;

3.生成索引;

4.啟動(dòng) searchd 服務(wù)進(jìn)程,默認(rèn)是9312

5.用 PHP 去連接 sphinx 服務(wù)

啟動(dòng) sphinx

cd /usr/local/coreseek/bin/./searchd

啟動(dòng)命令

searchd 命令參數(shù)介紹:

-c 指定配置文件

--stop 停止服務(wù)

--pidfile 用來顯式指定一個(gè) PID 文件

-p 指定端口

5、php 安裝 sphinx?擴(kuò)展

sudo pecl install sphinx

如果出現(xiàn)錯(cuò)誤:“configure: error: Cannot find libsphinxclient headers”

解決方法:

cd coreseek-4.1/csft-4.1/api/libsphinxclient/./configure --prefix=/usr/local/libsphinxclientsudo make && make install

解決完畢!

回去接著執(zhí)行

./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/libsphinxclient

sudo make && make install

出現(xiàn)類似“Installing shared extensions: /usr/lib/php5/20090626/sphinx.so”,表示成功。

可以進(jìn)入該目錄下會(huì)發(fā)現(xiàn)生成了一個(gè) sphinx.so 文件

在 php.ini 中加載該 so 文件

extension=/usr/lib/php5/20090626/sphinx.so

重啟 apache ,phpinfo() 中出現(xiàn)這個(gè)表明成功。

標(biāo)簽: PHP
相關(guān)文章:
主站蜘蛛池模板: av性色 | 成人在线欧美 | 久久综合中文字幕 | 一道本一二三区 | 亚洲成人精品在线观看 | 国产成人精品久久久 | 久久a视频 | 亚洲激情视频在线观看 | 国产精品久久久久久久久费观看 | 精品久久网站 | 高清三区 | 激情国产| 狠狠躁日日躁夜夜躁东南亚 | 第四色影音先锋 | 久久亚洲一区二区 | 成人 在线 | 国产精品久久久久久影院8一贰佰 | 极品久久 | 国产精品久久久久久久久免费桃花 | 欧美国产精品一区 | 欧美日韩国产精品 | 国内成人精品2018免费看 | 午夜影院免费 | 国产欧美精品一区二区三区四区 | 国产一区二区三区四区三区 | 伊人激情网 | 毛片久久 | 影音先锋中文字幕在线 | 操操操操操操操操操操操操操操 | 久久国产一区二区 | 久久久久久久99精品免费观看 | 奇米色欧美一区二区三区 | av在线干 | 国产精品久久久久久久久 | 欧美自拍视频在线 | 在线日韩视频 | 欧美视频在线播放 | 成人午夜免费视频 | 久久久久久久国产精品 | 日韩在线视频一区 | 精品天堂 |