You could go with Ubuntu 10.04 Lucid. Security support runs out for that in less than a year, but that should give you enough time to patch your PHP.
In my opinion using an Ubuntu-supported package is preferable to compiling from source, and 10.04 does happen to have the version you want as its official package.
Eventually you are going to have to patch your PHP code, however. It shouldn't be that difficult to bring it into compatibility with later PHP versions: all issues will be well documented online, and there will only be a small number of issues that would affect backward compatibility. Older versions of PHP won't be supported forever and eventually you'll end up with security problems if you stick with PHP versions that are not officially supported.