diff --git a/src/infrastructure/setup/PhabricatorSetup.php b/src/infrastructure/setup/PhabricatorSetup.php index 6398b2fa8e..e24a18a98c 100644 --- a/src/infrastructure/setup/PhabricatorSetup.php +++ b/src/infrastructure/setup/PhabricatorSetup.php @@ -147,19 +147,63 @@ class PhabricatorSetup { } } - list($err, $stdout, $stderr) = exec_manual( - '/usr/bin/env php -r %s', - 'exit;'); + list($err, $stdout, $stderr) = exec_manual('which php'); if ($err) { self::writeFailure(); - self::write("Unable to execute 'php' on the command line from the web ". + self::write("Unable to locate 'php' on the command line from the web ". "server. Verify that 'php' is in the webserver's PATH.\n". " err: {$err}\n". "stdout: {$stdout}\n". "stderr: {$stderr}\n"); return; + } else { + self::write(" okay PHP binary found on the command line.\n"); + $php_bin = trim($stdout); + } + + // NOTE: In cPanel + suphp installs, 'php' may be the PHP CGI SAPI, not the + // PHP CLI SAPI. proc_open() will pass the environment to the child process, + // which will re-execute the webpage (causing an infinite number of + // processes to spawn). To test that the 'php' binary is safe to execute, + // we call php_sapi_name() using "env -i" to wipe the environment so it + // doesn't execute another reuqest if it's the wrong binary. We can't use + // "-r" because php-cgi doesn't support that flag. + + $tmp_file = new TempFile('sapi.php'); + Filesystem::writeFile($tmp_file, '