Apache Thrift Hello World with PHP and Python Part 1

In the previous post, I shared you the way how to install Apache Thrift in Ubuntu server. And now, I am writing the first application named Hello World with Apache Thrift in Python and Laravel 4.2

Concept:

You could clone full source from here: https://github.com/thanhson1085/thrift-laravel

Please download the source code before reading next steps.

You never know how strong you are, until being strong is your only choice

You never know how strong you are, until being strong is your only choice

Step 1: Create thrift files hello.thirft and exceptions.thrift

hello.thrift:

exceptions.thrift:

Step 2:  Run thrift compiler command to generate source code

See the details at gen.sh file

Step 3: Code the server-side

Code Hello Server hello-server.py (located src/python directory):

Create Hander hander.py located in src/python/hello:

Step 4: Run a test

Finally, test the server with server.sh script:

The output will be as below:

That means that you created server-side successfully.

Please keep reading Part 2 to know how to code the client-side with PHP Laravel 4.2

 

Install Apache Thrift from source in Ubuntu 14.04

Apache Thrift helps you build scalable cross-language services.  It supports C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml. It is really helpful if you want to scale your system base on HTTP protocol. And the below is a tutorial help you are able install Apache Thrift in Ubuntu 14.04.

Actually, It is easily to install it with command:

But with building from source code, there is more complicate than that. See the below.

Preparing libraries:

Install JAVA:

Clone Thrift source and make install:

Testing:

 

Install mysql 5.1 in ubuntu 14.04

How to install mysql 5.1 in ubuntu 14.04? Actually, it is easy to install mysql version 5.5. However, with version 5.1, it is so difference. You have to install this from source.

Download mysql 5.1 source code:

Uncompress the packet:

Install dependencies:

Install from source:

Create mysql data directory and mysql user

DB install

And try to run mysql