I have PHP running using FastCGI on my APIdoc site.
I compiled PHP 5.1.1 with --enable-fastcgi and copied the php binary into my web directory as cgi-bin/php.fcgi. In my .htaccess file I've added a PHP handler that points to php.fcgi:
AddHandler custom-php .php
Action custom-php /cgi-bin/php.fcgi
If you just want magic_quotes_gpc switched off, you may want to take a look at Dreamhost's existing PHP 5 configuration. This has magic_quotes_gpc and register_globals switched off.