Linux系统安装SCWS-1.2.3及PHP扩展
来源:互联网 发布:闻道软件 编辑:程序博客网 时间:2024/06/11 15:30
取得 scws-1.2.3 的代码
wget http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2
解开压缩包
[hightman@d1 ~]$ tar xvjf scws-1.2.3.tar.bz2
进入目录执行配置脚本和编译
[hightman@d1 ~]$ cd scws-1.2.3[hightman@d1 ~/scws-1.2.3]$ ./configure --prefix=/usr/local/scws[hightman@d1 ~/scws-1.2.3]$ make[hightman@d1 ~/scws-1.2.3]$ make install
注:这里和通用的 GNU 软件安装方式一样,具体选项参数执行 ./configure –help 查看。
常用选项为:–prefix=
[hightman@d1 ~/scws-1.2.3]$ ls -al /usr/local/scws/lib/libscws.la
试试执行 scws-cli 文件
[hightman@d1 ~/scws-1.2.3]$ /usr/local/scws/bin/scws -hscws (scws-cli/1.2.3)Simple Chinese Word Segmentation - Command line usage.Copyright (C)2007 by hightman....
用 wget 下载并解压词典,或从主页下载然后自行解压再将 *.xdb 放入 /usr/local/scws/etc 目录中
[hightman@d1 ~/scws-1.2.3]$ cd /usr/local/scws/etc[hightman@d1 /usr/local/scws/etc]$ wget http://www.xunsearch.com/scws/down/scws-dict-chs-gbk.tar.bz2[hightman@d1 /usr/local/scws/etc]$ wget http://www.xunsearch.com/scws/down/scws-dict-chs-utf8.tar.bz2[hightman@d1 /usr/local/scws/etc]$ wget http://www.xunsearch.com/scws/down/scws-dict-cht-utf8.tar.bz2[hightman@d1 /usr/local/scws/etc]$ tar xvjf scws-dict-chs-gbk.tar.bz2[hightman@d1 /usr/local/scws/etc]$ tar xvjf scws-dict-chs-utf8.tar.bz2[hightman@d1 /usr/local/scws/etc]$ tar xvjf scws-dict-cht-utf8.tar.bz2
写个小程序测试一下
[hightman@d1 ~]$ cat > test.c#include <scws.h>#include <stdio.h>main(){ scws_t s; s = scws_new(); scws_free(s); printf("test ok!\n");}
编译测试程序
[hightman@d1 ~]$ gcc -o test -I/usr/local/scws/include -L/usr/local/scws/lib test.c -lscws -Wl,--rpath -Wl,/usr/local/scws/lib[hightman@d1 ~]$ ./test
这样就好顺利安装完毕可以使用 libscws 这套 C-API 了
安装 php 扩展
假设您已经将 scws 按上述步骤安装到 /usr/local/scws 中。
安装此扩展要求您的 php 和系统环境安装了相应的 autoconf automake 工具及 phpize 。
- 进入源码目录的 phpext/ 目录 ( cd ~/scws-1.2.3 )
- 执行
phpize
(在PHP安装目录的bin/目录下) - 执行
./configure --with-scws=/usr/local/scws
若 php 安装在特殊目录$php_prefix
, 则请在configure
后加上--with-php-config=$php_prefix/bin/php-config
- 执行
make
然后用 root 身份执行make install
在 php.ini 中加入以下几行
[scws]
;
; 注意请检查 php.ini 中的 extension_dir 的设定值是否正确, 否则请将 extension_dir 设为空,
; 再把 extension = scws.so 指定绝对路径。
;
extension = scws.so
scws.default.charset = utf8
scws.default.fpath = /usr/local/scws/etc重启php使新的 php.ini 生效。命令行下执行 php -m 就能看到 scws 了或者在 phpinfo() 中看看关于 scws 的部分。
- 如果重启php-fpm过程中出现错误信息
NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/opt/rh/php55/root/usr/lib64/php/modules/scws.so' - libscws.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
则需要建两个软连接:ln -s /usr/local/scws/lib/libscws.so.1.1.0 /usr/local/lib/libscws.so
ln -s /usr/local/scws/lib/libscws.so.1.1.0 /usr/local/lib/libscws.so.1
- 这样就算安装完成了,余下的工作只是PHP代码编写问题了。
0 0
- Linux系统安装SCWS-1.2.3及PHP扩展
- 中文分词插件SCWS-1.2.3 在Linux环境的安装说明(包括php扩展)
- PHP中文分词扩展 SCWS
- phpcms 安装 SCWS分词扩展
- 编译PHP的SCWS中文分词扩展
- Linux 系统下sphinx的安装及php扩展的配置流程
- php中文分词系统SCWS的用法
- SCWS-1.2.2 安装说明
- Linux下安装Redis及安装php扩展
- linux(ubuntu) memcache安装及php的memcache扩展安装
- php linux 环境安装配置 及 扩展安装
- linux php安装扩展
- linux安装php扩展
- 开源php中文分词系统SCWS安装和使用实例_php实例
- centos6.4 32位系统安装mongodb及php扩展
- CentOS系统安装Redis及Redis的PHP扩展
- CentOS系统安装Redis及Redis的PHP扩展
- linux系统下php源码安装redis扩展
- 解决安卓动画setFillAfter无效的问题
- volley使用简介
- 5.11
- 客户机操作系统已禁用 CPU。请关闭或重置虚拟机。
- 简单高效的web服务器测试工具Artillery(websocket http)
- Linux系统安装SCWS-1.2.3及PHP扩展
- php面试内容 让你轻松面试PHP程序员
- HDU 5878 二分法+打表 I Count Two Three
- @RequestMapping返回值为void
- 第4周项目3-(1)单链表应用、结点逆置
- AIDL
- 2016/09/22 10:19
- 使用Python分析社交网络数据
- location.search是什么意思?怎么用?