RPC - Install

RPC - Install

Thrift

apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev
apt-get install php5-dev php5-cli node
apt-get install make

cd /tmp/
wget https://dist.apache.org/repos/dist/release/thrift/0.9.0/thrift-0.9.0.tar.gz
tar xvzf thrift-*.tar.gz
cd thrift-*/
./configure
make
make install

thrift -version
ps aux | grep thrift

Mandatory Tweaks

Still, there are couple of things to do. First of all, there is a PHP extension () that speeds up encoding-decoding process in Thrift protocol.

Use PHP extension

Let’s find out where our CLI PHP looks for additional .ini files to include in php.ini:

php -i | grep -i "Scan this dir"

Our thrift_protocol.ini is put inside /etc/php.d/ by default, so we need to move it to the right place:

mv /etc/php.d/thrift_protocol.ini /etc/php5/conf.d

That should do it.

Save your lib for PHP before you delete sources

Let’s create a small archive of it, that we will in a future distribute with every project we do. And move this archive somewhere because you will often need this:

tar -zcvf thrift-phplib.tar.gz /tmp/thrift-*/lib/php/src/ --exclude=ext
mv thrift-phplib.tar.gz /vagrant

Now, whenewer you start a project, you will unpack that:

mkdir lib && tar -zxvf thrift-phplib.tar.gz -C lib/ --strip=5

Zookeeper

apt-get install zookeeper zookeeper-bin zookeeperd

Start it in standalone mode:

/usr/share/zookeeper/bin/zkServer.sh start

Default port number for clients to connect is 2181, and that is configurable via: /etc/zookeeper/conf/zoo.cfg

PHP extension

We need a PEAR to install thic PECL extension.

apt-get install php-pear libzookeeper-mt-*

To install extension, type (there is a warning on beta):

pecl install zookeeper-beta

In my system, extrension is put where it should be:

/usr/lib/php5/20090626/zookeeper.so

and, now the only thing to do manualy is to add it to the php.ini:

echo "extension=zookeeper.so" >/etc/php5/conf.d/zookeeper.ini

There are commands for Zookeeper ( sleep 1; echo “conf”; sleep 1; ) | telnet localhost 2181

libzookeeper-java: Core Java libraries for zookeeper libzookeeper-java-doc: API Documentation for zookeeper libzookeeper-mt-dev: Development files for multi threaded zookeeper C bindings libzookeeper-mt2: Multi threaded C bindings for zookeeper libzookeeper-st-dev: Development files for single threaded zookeeper C bindings libzookeeper-st2: Single threaded C bindings for zookeeper libzookeeper2: C bindings for zookeeper - transitional package python-zookeeper: Python bindings for zookeeper zookeeper: High-performance coordination service for distributed applications zookeeper-bin: Command line utilities for zookeeper zookeeperd: Init control scripts for zookeeper

Build process completed successfully Installing ''

You should add “extension=zookeeper.so” to php.ini

PHP Composer package for Thrift PHP Libraries leric/php-thrift-package

Thrift Integration Examples

Example for me: Integrate Thrift into Symfony 2 project ebuzzing/OverblogThriftBundle · GitHub

date 01. Jan 0001 | modified 28. May 2021
filename: RPC - Install