首页 > 代码库 > php扩展trie_filter的实践

php扩展trie_filter的实践

trie_filter是屏蔽敏感词的非常有用的扩展。以下是我的实践。

ubuntu1404 + php5.3.29 + libiconv-1.13.1 + libdatrie


  1. 安装libiconv

    wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz

    tar zxvf libiconv-1.13.1.tar.gz

    cd libiconv-1.13.1

    ./configure –prefix=/usr/local

    make
    make install

  2. 安装libdatrie

    sudo apt-get update

    sudo apt-get install libdatrie-dev

3. 下载php5.3.29包编译

    ./configure --with-iconv=/usr/local/lib

4. 获取trie_filter扩展包

 git clone https://github.com/wulijun/php-ext-trie-filter.git

 编译

$ $INSTALL_PHP_PATH/bin/phpize
$ ./configure --with-php-config=$INSTALL_PHP_PATH/bin/php-config --with-trie_filter=$LIB_PATH
$ make
$ make install

5.测试

 php -m | grep trie_filter

 php -r "var_dump(function_exists(‘trie_filter_save‘));"

本文出自 “犀牛” 博客,请务必保留此出处http://rhino.blog.51cto.com/5504750/1874634

php扩展trie_filter的实践