The php CGI module is pretty easy to compile. If you are in a unix enviornment, just unpack the tarball (in the directory with the php .tar.gz type tar xvfz php-x.x.x.tar.gz) and then move to the newly created directory php-x.x.x (cd php-x.x.x).
Now, once inside this directory, you need to type './configure ...' this will set up the build for your current platform. Next, simply type 'make' at the command line and hit enter. This will compile the sources. It will give you a message once complete. Now that we have that done, just type 'make install' and the binary will be copied (by default) to /usr/local/bin/php where you can use it in shell scripts. Hope that helps!
Chris King