note 94912 deleted from features.commandline by cmb
| From: | cmb@php.net | Date: | Sun, 30 Jun 2019 09:51:02 +0000 |
| Subject: | note 94912 deleted from features.commandline by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211431@lists.php.net to get a copy of this message | ||
Note Submitter: kazink at gmail dot com
----
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 the command line into the $_GET variable
parse_str($_SERVER['QUERY_STRING'], $_GET);
//parse the standard input into the $_POST variable
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.