How do I install PHP as a CGI?

What you need to do is to run:

./configure --without-apache --without-apxs --with-other-options

It will tell you that as you are building it without Apache support, it is building it as a CGI binary.

Then do make ; make install and it should then be installed (/usr/local/bin/php by default)