I had problems running php as CGI in thttpd. I have followed instructions posted by db at digitalmediacreation dot ch, but I was still getting "500 Internal Error" answer from the server. However, I had no problems running php as CLI using a simple wrapper file named index.cgi:
#!/usr/bin/php
<?php
require_once 'index.php';
?>
but i needed to pass user data through GET and POST, and this method couldn't handle it. I have spent 2 hours figuring out how to run the CGI mode properly, until I finally gave up, and done it in "manual" way. I have just added some code to the wrapper that reads GET and POST data into the proper variables:
#!/usr/bin/php
<?php
parse_str($_SERVER['QUERY_STRING'], $_GET);
if (($_SERVER['REQUEST_METHOD'] === 'POST')
&& ($_SERVER['CONTENT_LENGTH'] > 0))
{
parse_str(fread(STDIN, $_SERVER['CONTENT_LENGTH']), $_POST);
}
require_once 'index.php';
?>
It works well for me. It may be useful if someone else have similar problem.