How can I upgrade PHP on a jailbroken iPhone?
If you build the iPhone toolchain in you local environment, you can compile PHP locally and then move it to iOS.

https://stackoverflow.com/questions/4001510/compile-php-with-gd-for-iphone-os-4-1

http://george.insideiphone.com/index.php/iphone-toolchain/

http://code.google.com/p/iphone-dev/

http://www.sj99.com/toolchain.html

I've not done this, but I'm curious, and will make an attempt myself over the next few days, and update this answer as I go along.