*** DISCLAIMER: All content provided here including the scripts is provided without any warranty. You use it at your own risk. I can not be held responsible for any damage that may occur because of it. By using the scripts I provide here you accept this terms.
Please bear in mind that this method is intended for development and testing purposes only. If you care about stability and security you should use the packages provided by your distribution.
In this tutorial I will compile a LEMP stack with the latest NginX and PHP with FPM, MySQL, Suhosin and APC on Ubuntu Quantal(12.10). Apart for some version numbers for some dependencies, all the steps should be the similar for Ubuntu Lucid, Maverick, Natty and Oneiric.
I will not explain how to configure NginX here. You can find a lot of resources about that on the nginx wiki.
In order to compile these programs you will need the following dependencies (most of them should already be installed):