I guess the trick is knowing WHERE to call the commands....
If you can find the PHP source, go there and then
Set the environment (the VAR=whatever and export stuff);
$./configure --with-long-list-of-options-and=/their/paths
$make
$make install
....should about take care of it. Disclaimer, using "make" is always a learning experience, as you're learning.
dalecosp