title: How to disable _force-cgi-redirect_ in PHP compilation?
body: <p>I am working with PHP 7 (or trying to) and am at wits end trying to find a way to disable the <strong>force-cgi-redirect</strong> feature. No matter what I try, it seems to still always build the <em>php-cgi</em> binary with that option.</p>
  
  <p>I've tried adding the following line to both <strong>php.ini-development</strong> and <strong>php.ini-development</strong> in the project directory:</p>
  
  <pre><code>cgi.force_redirect = 0
  </code></pre>
  
  <p>That didn't work - so I also added the <strong>--disable-force-cgi-redirect</strong> to the <em>./configure</em> command line - and that also didn't work.</p>
  
  <p>I've Googled and Googled for a solution -- and came up with nothing but the first of the two things I tried and (when I got very specific) also the second of the two things I tried.</p>
  
  <p>I am aware of the security risks of disabling this "feature" -- but the context for which I need PHP 7 is one where FastCGI does not apply.</p>
  
  <p>As the server's default is PHP 5, the only way I can work on PHP 7 is if I can do it as a CGI script in which the first line is:</p>
  
  <pre><code>#! /my/home/directory/local/bin/php-cgi
  </code></pre>
  
  <p>.. and where PHP 7 is at that location because I compiled it with the <strong>--prefix= /my/home/directory/local"</strong> option - and I need it to run, once invoked that way, the same way as it would were it invoked by the server directly.</p>
  
  <p>However, I am prevented from doing this because, no matter what I do, I can't seem to disable the <strong>force-cgi-redirect</strong> feature.</p>
  
  <p>I can get the script to run if it is invoked with the <strong>/my/home/directory/local/bin/php</strong> interpreter rather than the <strong>/my/home/directory/local/bin/php-cgi</strong> interpreter - but this does not help me, as this solution results in PHP 7 behaving in the command-line manner (little, yet important differences, such as no header output).</p>
  
  <p><strong>NOTE:</strong> For testing purposes (so that I could see what was going wrong) I also attempted to write a CGI script similar to the following one (say it is called "phptest.cgi"):</p>
  
  <pre><code>#! /bin/bash
  
  echo "Content-type: text/plain"
  echo ""
  
  /my/home/directory/local/bin/php-cgi phptest.php
  </code></pre>
  
  <p>That is how I found out that the problem was the <strong>force-cgi-redirect</strong> feature -- as before doing this, all I got was the nebulous notification that a server error had occurred.</p>