Thrift是一個開源的RPC框架,由知名SNS社區FaceBook貢獻。下面記錄了在Ubuntu 10.04下編譯安裝Thrift的全過程。
1、編譯安裝依賴
安裝Java(除非你不想RPC使用Java)
add-apt-repository "deb http://archive.canonical.com/ lucid partner"
apt-get update
apt-get install sun-java6-jdk sun-java6-plugin
編譯安裝MySQL(主要是為了php5)
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.53.tar.gz/from/http://sunsite.informatik.rwth-aachen.de/mysql/
tar -xzvf mysql-5.1.53.tar.gz
#配置
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti"
./configure –prefix=/usr/local/mysql –enable-assembler –with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock –with-mysqld-ldflags=-all-static –with-client-ldflags=-all-static –with-extra-charsets=gb2312,gbk,utf8,latin1 –without-debug –with-charset=utf8 –with-collation=utf8_general_ci –with-pthread –enable-static –enable-thread-safe-client
#編譯安裝
make
sudo make install
其他配置請參考:CentOS 5.4編譯安裝MySQL 見 http://www.linuxidc.com/Linux/2011-12/50209.htm
編譯安裝php(一定要dev的)
sudo apt-get install php5-dev
2、編譯安裝Thrift
我主要需要同時支持C++和PHP的,能支持Python最好
wget
tar -xzvf
./configure
還要單獨安裝php的支持文件
sudo mkdir -p /usr/share/php/Thrift
cd /home/liheyuan/code/thrift-0.5.0/lib/php/src
sudo cp -rf * /usr/share/php5/Thrift/
3、手動編譯php的拓展
其實不用拓展也可以用,但是編譯拓展的話性能會很好
cd ~/code/thrift-0.5.0/lib/php/src/ext/thrift_protocol
phpize
./configure –enable-thrift_protocol
make
sudo make install
還要在php的ini中啟用
sudo vim /etc/php5/conf.d/thrift_protocol.ini
#寫入
extension=thrift_protocol.so
補充:不需要php時候的configure
./configure –prefix=/usr –without-ruby –without-haskell –without-python –without-perl –without-php –without-php_extension