note 94912 added to features.commandline
| From: | kazink at gmail dot com | Date: | Wed, 02 Dec 2009 11:58:46 +0000 |
| Subject: | note 94912 added to features.commandline | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163483@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 82.177.164.100
Probable Submitter: 212.182.91.35
----
Manual Page -- http://www.php.net/manual/en/features.commandline.php
Edit -- https://master.php.net/note/edit/94912
Del: integrated -- https://master.php.net/note/delete/94912/integrated
Del: useless -- https://master.php.net/note/delete/94912/useless
Del: bad code -- https://master.php.net/note/delete/94912/bad+code
Del: spam -- https://master.php.net/note/delete/94912/spam
Del: non-english -- https://master.php.net/note/delete/94912/non-english
Del: in docs -- https://master.php.net/note/delete/94912/in+docs
Del: other reasons-- https://master.php.net/note/delete/94912
Reject -- https://master.php.net/note/reject/94912
Search -- https://master.php.net/manage/user-notes.php