準備源碼包:sphinx-2.1.1;Sphinx的PHP模塊:sphinx-1.1.0;結合中文分詞的sphinx:coreseek-3.2.14
上傳sphinx源碼包到服務器,解壓並安裝:tar -zxvf sphinx-2.1.1 cd sphinx-2.1.1 ./configure --prefix=/usr/local/sphinx --with-mysql=/usr make && make install;
這裏配置./configure的時候遇到問題:configure:error:invalid MySQL root directore 'usr/bin';neither bin/mysql_config,nor include/ and lib/ were found where。
因爲之前mysql是一鍵安裝的,所以安裝目錄分散在多個地方,不知道--with應該寫哪一個目錄。試了所以目錄都沒有作用,百度查找答案發現是少了libmysqlclient-dev,
於是安裝libmysqlclient-dev;此時又有報錯:提示沒有源,運行命令更新源:apt-get update;然後繼續執行:apt-get install libmysqlclient-dev
繼續執行./configure成功然後make && make install
安裝爲模塊之前先得安裝libsphinxclient。將coreseek-3.2.14源碼包上傳到服務器解壓tar-zxvf coreseek-3.2.14
然後進入coreseek-3.2.14/csft-3.2.14/api目錄
看到有一個libsphinxclient的目錄,進入該目錄cd libsphinxclient
執行命令:./configure
然後編譯並安裝:make && make install
這時可以去安裝PHP sphinx模塊:
上傳sphinx-1.1.0.tgz然後解壓進入;接着運送phpize指令;會出現configure指令
配置:./configure --with-php-config=/usr/bin/php-config(路徑根據自己的實際路徑寫)
然後編譯:make
這裏會有個報錯:make: *** [sphinx.lo] Error 1
將sphinx.c的105行修改爲如下:
retval = std_hnd->read_property(object, member, type TSRMLS_CC, NULL);
然後:make && make install
安裝成功:
最後在php.ini文件中加上:
extension=sphinx.so
然後重啓服務器:查看phpinfo
完成!
軟件下載百度雲連接: https://pan.baidu.com/s/1RrGlG6ZmSDVOJ6K-VgHXEg 密碼: yaan