Homec4science

Detect which PHP SAPI the CLI binary uses during setup

Authored by epriestley <git@epriestley.com> on Jan 13 2012, 20:29.

Description

Detect which PHP SAPI the CLI binary uses during setup

Summary:

  • PHP uses a SAPI ("server API") to determine how it interacts with the caller

(e.g., how to read the environment, how to read flags, what code to execute).

  • There are several different SAPIs: cli, cgi, cgi-fcgi, apache, etc.
  • Each SAPI has different behavior -- for instance, the "cgi" SAPI emits some

CGI headers unless told not to, so a script like 'echo "x"' actually echoes some
headers and then 'x' as an HTTP body.

  • In some setups, "php" may be php-cgi.
  • If you run php-cgi as "php scriptname.php" and your ENV has an existing CGI

request in it, it runs that CGI request instead of the script. This causes an
infinite loop.

  • Add checks to verify that "php" is the "cli" SAPI binary, not some other

SAPI.

  • In particular, cPanel uses suphp and is affected by this configuration

issue. See this thread:
https://lists.marsching.com/pipermail/suphp/2008-September/002036.html

Test Plan:

  • On a cPanel + suphp machine, ran setup and was stopped for having the

"cgi-fcgi" SAPI instead of throw into an infinite loop.

  • Applied the suggested remedy, setup now runs fine.

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, btrahan, epriestley

Differential Revision: https://secure.phabricator.com/D1390

Details

Committed
epriestley <git@epriestley.com>Jan 13 2012, 20:54
Pushed
aubortJan 31 2017, 17:16
Parents
rPHcf61f0e32dd1: Adding an "ssh" client for conduit
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHb71e1c15ef93: Detect which PHP SAPI the CLI binary uses during setup (authored by epriestley <git@epriestley.com>).Jan 13 2012, 20:54