If anyone is still looking to install php 5.4 and wants to create a stand-alone install of php 5.4 from source, this is how do do it:
Create a folder named php-5.4 in your local home directory like ~/programs/php-5.4. Then execute below commands from it through CLI.
sudo apt-get install gcc libmysqlclient-dev libxml2-dev wget --trust-server-names http://museum.php.net/php5/php-5.4.15.tar.bz2 tar xjf php-5.4.15.tar.bz2 cd php-5.4.15 ./configure --prefix=$PWD/installdir --enable-bcmath --with-mysql make install cd -
Replace 5.4.15 with the latest old-stable version of php. Refer this Google appengine developer page for more details.
edit
Updated the new location for php 5.4.