At the risk of being attacked by all of those who won't even consider running PHP if it hasn't been compiled by them, I admit I had never done it before. I always run Drupal on whatever PHP I get from the OS repositories, but there is a first time for everything.
A client hired us at SeeD E.M. to develop a Drupal site for them, and at their request, it had to use PHP 5.2.x and MySQL 5.1.x. We haven't developed on PHP 5.2 for a while now, and although what we do shouldn't be incompatible with it, we wanted to be sure. At first we thought of installing an Ubuntu 8.04 and develop on it, but we quickly trashed the idea, that is such an old OS! Which then led me to think this was the perfect opportunity to compile PHP by myself for the first time.
We had an Ubuntu 10.04 with nothing important in it (mostly a play ground machine), which I took and used to run my experiment (as if no one had ever done this before, but whatever). It was perfect because it comes with MySQL 5.1 which means after compiling PHP I was done. Compiling PHP is nothing new, and there are plenty of posts out there explaining what and how to do it, but what I couldn't find was what minimal options I had to use so that I could run Drupal, and after a few tries this is what I came up with:
I installed Apache and MySQL first with aptitude (use apt-get if you like it better):
aptitude install mysql-server libapache2-mod-php5
and after compiling PHP I was done.
Installing libapache2-mod-php5 also installs php5-commons, which means you already have php installed on your system, but after compiling and installing PHP the default apache module will be overriden by your own.
I have to admit it was way easier and less exciting than I though it would be. I expected problems, and Drupal not running, and MySQL crashing, and plenty of nasty error messages, and having to go trhough endless logs and pretty much my machine burning down; but nothing like that happened, it just worked.