天天看点

centos7下安装thrift

目录

    • 1. 安装centos需要的扩展
    • 2. 安装boost,本地源码安装最安全
    • 3. 安装thrift ,不要用git包,直接到官网上下载tar包
    • 4. 安装完成

1. 安装centos需要的扩展

yum install -y automake libtool flex bison pkgconfig gcc-c++ libevent-devel zlib-devel python-devel ruby-devel openssl-devel

  yum install -y boost-devel # 非源码安装boost
  yum install -y byacc
  yum install -y bzip2-devel
  yum install -y wget
           

注意:安装完第一步,直接进行第三步安装thrift

若是成功,就不用管第二步了,因为源码安装boost太慢了

2. 安装boost,本地源码安装最安全

yum install -y wget

wget http://sourceforge.net/projects/boost/files/boost/1.72.0/boost_1_72_0.tar.gz
tar -xvf boost_1_72_0.tar.gz
cd boost_1_72_0

./bootstrap.sh --prefix=/usr/local
./b2 install   
           

3. 安装thrift ,不要用git包,直接到官网上下载tar包

centos7 下安装的依赖库都一样,在安装boost时,需要指定目录安装;

因为使用默认boost安装方式时,centos7下boost生产会把产生的库安装在/usr/local/lib目录下,

而安装thrift时默认的是/usr/local/lib64目录,所以会导致错误,找不到文件。

wget "http://mirror.bit.edu.cn/apache/thrift/0.12.0/thrift-0.12.0.tar.gz"
tar -xvf thrift-0.12.0.tar.gz
cd thrift-0.12.0

# ./configure是用来生成Makefile文件的
# 指定boost库所在目录 --with-boost=/usr/local/
# 指定不需要lua --with-lua=no
./configure --with-boost=/usr/local/ --with-lua=no
make 
make install
           
出现报错1:找不到libboost_unit_test_framework.a
解决:源码本地编译boost安装

ln -s /usr/local/lib/libboost_unit_test_framework.a /usr/lib64/libboost_unit_test_framework.a

ln -s /usr/local/lib/libboost_unit_test_framework.a /usr/local/lib64/libboost_unit_test_framework.a

解决完后,继续make
           

4. 安装完成

[[email protected] thrift-0.12.0]# thrift --version
Thrift version 0.12.0