使用PHP7扩展trie_filter 敏感词过滤

最近需要做一个简单的敏感词检测系统,
通过百度找到了 trie_filter 这个扩展.安装这个扩展真是一波三折呀.原作者最后更新时间是13年,不支持php7.很愁很苦恼.但是最后还是很愉快的解决了.下面和大家分享一下

安装php-ext-trie-filter扩展前需要安装他的依赖库libdatrie,依赖库下载地址:http://linux.thai.net/~thep/datrie/datrie.html#Download

我们使用0.2.12版

 cd /usr/local/src/
 curl -O ftp://linux.thai.net/pub/ThaiLinux/software/libthai/libdatrie-0.2.12.tar.xz
 tar zxvf libdatrie-0.2.12.tar.xz
 cd libdatrie-0.2.12
 make clean
 ./configure --prefix=/usr/local/libdatrie
 make
 make install

在 第一次安装这个依赖的时候 make clean 这条命令会报错 无视即可.

安装完成后.我们开始安装 trie_filter 扩展,我在GitHub上找到一份别人修改好支持php7的源码.我们下载下来 安装即可了

cd /usr/local/src/
 wget https://github.com/jiopuud/trie_filter/archive/master.zip
 unzip master.zip
 cd php-ext-trie-filter-master/
 phpize
 ./configure --with-php-config=/usr/bin/php/php-config --with-trie_filter=/usr/local/libdatrie
 make
 make install

在进行 下面这一步的时候 可能会提醒你 需要加上--with-php-config =

$ ./configure --with-php-config=/usr/bin/php-config --with-trie_filter=/usr/local/libdatrie
如果你不知道php-config的路径 可以用 find / -name php-config 来搜索

不出意外执行完这些操作就能安装好扩展.

最后一步!

修改php.ini,然后增加一行:extension=trie_filter.so,保存配置并重启php

非特殊说明,本博所有文章均为博主原创。

备注:相关侵权、举报、投诉及建议等,请联系站长

添加新评论

昵称
邮箱
网站