Dan Barrett has written up an excellent guide to setting up a LAMP stack on Debian from the ground up. It includes all the commands, configuration changes and screenshots of the interface you'll need.

Setting up a test environment can be a tricky thing when you compile PHP from scratch. As others have mentioned in the past, installations from Aptitude (and the like) lag behind which can quickly put your test environment out of date. Pulling inspiration from Juan Treminio and Brandon Savage, who both wrote excellent articles on setting up PHP from scratch. I like to keep my options open when developing which left both of those articles lacking a few features and extensions that I'd like to have bundled with PHP.

He guides you through a (detailed) process to get the following set up and running: