首先下載下傳 sphinx 最新版 2.2.11-release http://sphinxsearch.com/downloads/release/
sphinx php擴充下載下傳位址(目前已經支援php7):http://git.php.net/?p=pecl/search_engine/sphinx.git;a=shortlog;h=refs/heads/php7
scws下載下傳位址:http://www.xunsearch.com/scws/download.php
scws詞庫下載下傳位址:http://www.xunsearch.com/scws/down/scws-dict-chs-utf8.tar.bz2
安裝 sphinx
tar zxvf sphinx-2.2.11-release.tar.gz
cd sphinx-2.2.11-release
./configure --prefix=/usr/local/sphinx2 --with-mysql=/usr/local/mysql
make && make install
複制
有可能會出現下面的錯誤
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
Makefile:392: recipe for target 'sphinx.o' failed
make[2]: *** [sphinx.o] Error 4
make[2]: Leaving directory '/home/sphinx-2.2.11-release/src'
Makefile:244: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/sphinx-2.2.11-release/src'
Makefile:331: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
複制
解決辦法就是
修改 configure 檔案把 #define USE_LIBICONV 0 最後的數值由1改為0 重新編譯。
另外,編譯過程中 512記憶體的機子如果記憶體不足的話會碰到
g++: internal compiler error: Killed (program cc1plus) 的報錯。
安裝 sphinx 用戶端
cd api/libsphinxclient //sphinx-2.2.11-release目錄下
./configure --prefix=/usr/local/sphinx2/libsphinxclient
make && make install
複制
安裝 sphinx php 擴充
tar zxvf sphinx-339e123.tgz
cd sphinx-339e123
phpize
./configure --with-sphinx=/usr/local/sphinx2/libsphinxclient --with-php-config=/usr/bin/php-config
make && make install
複制
安裝 scws
tar xvjf scws-1.2.3.tar.bz2
# mkdir /usr/local/scws
# cd scws-1.2.3
# ./configure --prefix=/usr/local/scws/
# make && make install
複制
安裝 scws php 擴充
# cd ./phpext/
# phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
複制
安裝 scws 詞庫
# tar xvjf scws-dict-chs-utf8.tar.bz2 -C /usr/local/scws/etc/
# chown www:www /usr/local/scws/etc/dict.utf8.xdb
複制
配置 php.ini
# vim /usr/local/php/etc/php.ini
[sphinx]
extension = sphinx.so
[scws]
extension = scws.so
scws.default.charset = utf-8
scws.default.fpath = /usr/local/scws/etc
複制
重新開機 php-fpm 即可完成安裝