The following command install all the required tools and libraries to build and install the Apache Thrift compiler on a Debian/Ubuntu Linux based system.
sudo apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev
Then install the Java JDK of your choice. Type javac to see a list of available packages, pick the one you prefer and apt-get install it.
Debian Lenny Users need some packages from backports
sudo apt-get -t lenny-backports install automake libboost-test-dev
Some other packages depend on what languages you want Thrift to support.
For more information on the requirements see: Apache Thrift Requirements
For more information on building and installing Thrift see: Building from source