HomePhorge

Detect which PHP SAPI the CLI binary uses during setup

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

Provenance
epriestleyAuthored on Jan 13 2012, 11:29 AM
themackabuPushed on Mar 25 2025, 8:07 PM
Parents
rPcf61f0e32dd1: Adding an "ssh" client for conduit
Branches
Unknown
Tags
Unknown

Event Timeline