`
奔跑的羚羊
  • 浏览: 571404 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

thrift-0.5.0安装

阅读更多

yum install python python-devel

一、安装libevent
    http://www.monkey.org/~provos/libevent/
解压缩安装
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar zxvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure
make
make install



二、安装boost
      http://www.boost.org
(版本>=1.36) boost_1_45_0.tar.bz2
解压
wget  http://jaist.dl.sourceforge.net/project/boost/boost/1.55.0/boost_1_55_0.tar.gz
tar zxvf boost_1_55_0.tar.gz
cd boost_1_55_0
./bootstrap.sh
./bjam -s HAVE_ICU=1 --prefix=/usr/local/boost --includedir=/usr/local/boost/include --libdir=/usr/local/boost/lib
./bjam install --prefix=/usr/local/boost


添加环境变量
export BOOST_ROOT=/usr/local/boost
export LD_LIBRARY_PATH=/usr/local/boost/lib:/usr/local/lib/:/usr/lib/


三、安装thrift

1.安装php环境
1)必须先安装 libxml2 ,然后在安装 php,
下载:ftp://xmlsoft.org/libxml2/ ,下载libxml2-2.7.8.tar.gz
tar -xvf libxml2-2.7.8.tar.gz
./configure
make
make install


2)下载 php:  http://cn.php.net/downloads.php ,下载php-5.3.6.tar.gz
tar -vxf  php-5.3.6.tar.gz
./configure --prefix=/usr/local/php5 --with-php-config=/usr/local/php5/bin/php-config 
make
make install

(因为在 scribe 的一些版本中用到 php-config ,所以这里面要用 —with-php-config ,但是在我的安装过程没有用到,所以这个可以忽略)


2.安装thrift
        http://incubator.apache.org/thrift/
(版本>=0.5.0)
1)先安装thrift,
解压并进入thrift目录     
./configure --prefix=/usr/local/thrift --with-boost=/usr/local/boost --with-php-config=/usr/local/php5/bin/php-config
make
make install   


验证
$ thrift -version  
Thrift version 0.5.0


四、安装fb303
如果不需要,可以省略该步骤
Facebook Bassline (included in thrift/contrib/fb303/)
        fb303 r697294 or later is required.
        (已经包含在Thrift中了,重新编译一下fb303就可以)
cd ./contrib/fb303/
./bootstrap.sh --with-boost=/usr/local/boost
./configure --with-boost=/usr/local/boost --with-thriftpath=/usr/local/thrift
make
make install


安装完Thirft后,记得运行一下它提供的example,看是否安装成功。
验证:
cd ./thrift-0.5.0/tutorial
thrift -r -gen cpp tutorial.thrift  // -r对其中include的文件也生成服务代码 -gen是生成服务代码的语言

cd cpp
make

运行完之后会在当前目录看到一个gen-cpp目录,其中就是thrfit命令生成的代码。这时你cd到tutorial/cpp目录,运行make,生成相应的CppServer与CppClient程式。
此时你可以分别运行CppServer和CppClient,让它们通信。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics