How to compile and install thrift protocol extension from source

Thrift is a new way to share functionalities and resources between languages, to know more about it read the whitepaper above

http://incubator.apache.org/thrift/static/thrift-20070401.pdf

Before to start this instalation make sure that your PHP is installed and working in your computer.

Anyway to install PHP is very easy

Debian based

sudo aptitude install php5 php5-dev

Mac OS X

sudo port install php5 php5-devel

Now to start you should get the thrift source

http://thrift.apache.org/download/

After we have to extract the source

tar xzf thrift-0.6.1.tar.gz

Go to the extension path

cd thrift-0.6.1/lib/php/src/ext/thrift_protocol

Now configure your build and make

./configure
make && make test

Your extension already is compiled, go to modules path and see your extension ready to be used

cd modules && ls

If you want to get an extension already compiled, click in the link above
thrift_protocol.so

Now we will include this extension in our PHP environment, in my computer the path where I keep my extensions is /opt/local/lib/php/extensions, you can see this information in php.ini file or in phpinfo() function.

Copy the thrift_protoco.so to the extension path

sudo cp thrift_protocol.so /opt/local/lib/php/extensions

and add a reference to the extension in your php.ini file

extension=thrift_protocol.so  # you can also use the full path here

To finish restart your Apache

apacheclt restart


…to check if the extension was installed successfully run the phpinfo() function and verify if the thrift extension was included, any question please comment, I’ll try to help you as soon as posible.