mkdir scws
cd scws
wget http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2
tar xvjf scws-1.2..tar.bz2
cd scws-1.2.
./configure --prefix=/usr/local/scws
make && make install

# 下载字典

cd /usr/local/scws/etc
wget http://www.xunsearch.com/scws/down/scws-dict-chs-gbk.tar.bz2
wget http://www.xunsearch.com/scws/down/scws-dict-chs-utf8.tar.bz2
tar xvjf scws-dict-chs-gbk.tar.bz2
tar xvjf scws-dict-chs-utf8.tar.bz2

# 编译php扩展

cd /root/scws-1.2./phpext
phpize
./configure --with-scws=/usr/local/scws --with-php-config=/usr/local/php/bin/php-config
make && make install

#  在 php.ini 中加入以下几行

[scws]
extension=scws.so
scws.default.charset=gbk
scws.default.fpath=/usr/local/scws/etc

# 重启php

pkill php-fpm
/usr/local/php/sbin/php-fpm

# 在php程序中用 ini_get('scws.default.fpath') 读取scws.default.fpath目默认字典录设置

# 测试分词程序

php /root/scws-1.2./phpext/scws_test.php  //如果运行失败,很可能是未正确指定词典路径
05-07 14:51