RJ博客

Thrift框架安装

本文目录

http://thrift.apache.org/docs/install/centos

(注意 thrift 的make 要耗时比较长, 请耐心等待)


=======RPM安装包=======

thrift-0.9.0-28.1.x86_64.rar


# Thrift 安装
cd /dist/dist/
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
wget http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz
wget http://ftp.gnu.org/gnu/bison/bison-2.5.1.tar.gz
wget http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz
cd /dist/src
git clone https://git-wip-us.apache.org/repos/asf/thrift.git
yum install -y libtool flex bison pkgconfig gcc-c++ boost-devel python-devel libevent-devel zlib-devel ruby-devel openssl-devel
 
#更新 autoconf:
cd /dist/src
tar zxf ../dist/autoconf-2.69.tar.gz
cd autoconf-2.69
./configure --prefix=/usr
make
make install
 
#更新 automake:
cd /dist/src
tar zxf ../dist/automake-1.14.tar.gz
cd automake-1.14
./configure --prefix=/usr
make
make install
 
#更新 bison:
cd /dist/src
tar zxf ../dist/bison-2.5.1.tar.gz
cd bison-2.5.1
./configure --prefix=/usr
make
make install
 
#更新 Boost
cd /dist/src
tar zxf ../dist/boost_1_55_0.tar.gz
cd boost_1_55_0
./bootstrap.sh
./b2 install
 
#安装libevent2
cd /dist/src
tar zxf ../dist/libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure
make
make install
 
#安装thrift
yum install curl-devel
cd /dist/src
#tar zxf ../dist/thrift-1.0.0-dev.tar.gz
cd thrift
./bootstrap.sh
./configure --with-php=/usr/local/php --with-python --with-cpp --with-boost --without-csharp --without-java --without-erlang --without-perl --without-ruby --without-haskell --without-go --with-boost-libdir=/usr/local/lib
make
make install
 
#安装thrift.so
cd ./lib/php/src/ext/thrift_protocol/
/usr/local/php/bin/phpize
./configure -enable-thrift_protocol -with-php-config=/usr/local/php/bin/php-config
make
make install


遇到问题:

linux程序运行时加载共享库出现的错误:

"error while loading shared libraries: xxxx: cannot open shared object file: No such file or directory"

http://blog.sina.com.cn/s/blog_8d3bcbdb01012ea8.html

解决步骤:

1、使用find命令查找缺失的xxxx共享库文件所在位置。参考:#find 目录 -name "xxxx*"

2、将找到的目录位置写入 /etc/ld.so.conf 配置文件,这个文件记录了编译时使用的动态链接库的路径。

3、然后使用ldconfig命令,使配置生效。

clipboard.png

thrift/TDispatch processor.h No such file or directory error

此问题是由于thrift未完全成功安装导致


http://stackoverflow.com/questions/29212340/thrift-tdispatch-processor-h-no-such-file-or-directory-error

g++ -I /download/thrift/thrift/lib/cpp/src -c TimeService.cpp


安装扩展: 手动编译php的拓展 ( 需要gcc 4.8.2 以上版本才能编译c++11 )

其实不用拓展也可以用,但是编译拓展的话性能会很好

cd ./lib/php/src/ext/thrift_protocol/

/usr/local/php/bin/phpize

./configure -enable-thrift_protocol -with-php-config=/usr/local/php/bin/php-config

make

make install

还要在php的ini中启用

sudo vim /etc/php5/conf.d/thrift_protocol.ini

#写入

extension=thrift_protocol.so


make test 有出错

+-----------------------------------------------------------+
| ! ERROR ! |
| The test-suite requires that proc_open() is available. |
| Please check if you disabled it in php.ini. |
+---------------------------------------------
解决方法:
vi /usr/local/php/etc/php.ini
找到disable_functions = shell_exec, system, passthru, exec, popen, proc_open
改为disable_functions = shell_exec, system, passthru, exec, popen
保存退出。
make test
通过测试


相关推荐

发表评论