51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

基于wlnmp源安装的MySQL配置sphinx-for-chinese

sphinx-for-chinese是一款专门为中文优化的全文搜索软件,在sphinx的基础上添加了中文分词模块,不过该软件上次更新还在2013年,所以非必要,建议选择其它方式进行替代。

本文基于Centos7.x系统,MySQL5.7版本,由于sphinx-for-chinese本身过老,并已停止维护,较新的系统或MySQL版本可能不受支持。

1、安装一些依赖
yum install perl-devel openssl-devel gcc gcc-c++ make wget

|---|------------------------------------------------------------| | 1 | yum install perl-devel openssl-devel gcc gcc-c++ make wget |

2、添加wlnmp源
curl -fsSL "https://sh.wlnmp.com/wlnmp.sh" | bash

|---|----------------------------------------------------| | 1 | curl -fsSL "https://sh.wlnmp.com/wlnmp.sh" | bash |

3、通过wlnmp源安装MySQL
yum install wmysql57

|---|----------------------| | 1 | yum install wmysql57 |

4、下载sphinx-for-chinese
wget http://sphinxsearchcn.github.io/downloads/sphinx-for-chinese-2.2.1-dev-r4311.tar.gz

|---|------------------------------------------------------------------------------------------| | 1 | wget http://sphinxsearchcn.github.io/downloads/sphinx-for-chinese-2.2.1-dev-r4311.tar.gz |

5、解压缩并编译
tar xf sphinx-for-chinese-2.2.1-dev-r4311.tar.gz cd sphinx-for-chinese-2.2.1-dev-r4311 ./configure --prefix=/usr/local/sphinxforchinese --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib

|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 | tar xf sphinx-for-chinese-2.2.1-dev-r4311.tar.gz cd sphinx-for-chinese-2.2.1-dev-r4311 ./configure --prefix=/usr/local/sphinxforchinese --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib |


vim configure

|---|---------------| | 1 | vim configure |

将7804行1改为0

$as_echo "define USE_LIBICONV 0" >>confdefs.h
make -j 8 make install

|-----|------------------------| | 1 2 | make -j 8 make install |

至此编译成功,关于sphinx-for-chinese字典等相关配置的文章网上有很多,这里不再进行过多阐述,仅演示编译的过程,注意编译sphinx-for-chinese时,需要同时指定--with-mysql-includes和--with-mysql-libs。

赞(1)
未经允许不得转载:工具盒子 » 基于wlnmp源安装的MySQL配置sphinx-for-chinese