title: nginx + php-fpm without a .php extension
body: <p>This has come up a few times on SO but none of the solutions have worked.  This is what I currently have:</p>
  
  <pre><code>    location / {
              try_files $uri $uri/ $uri.php;
      }
  
      location @php {
              default_type application/x-httpd-php;
              fastcgi_param SCRIPT_FILENAME $request_filename;
              fastcgi_param QUERY_STRING    $args;
              fastcgi_pass unix:/var/run/php5-fpm.sock;
              fastcgi_index index.php;
              include fastcgi_params;
      }
  
      location ~ \.php$ {
              #fastcgi_split_path_info ^(.+\.php)(/.+)$;
              fastcgi_param SCRIPT_FILENAME $request_filename;
              fastcgi_param QUERY_STRING    $args;
              fastcgi_pass unix:/var/run/php5-fpm.sock;
              fastcgi_index index.php;
              include fastcgi_params;
      }
  </code></pre>
  
  <p>This example contains two options.  First, the first stanza is written to push URL/foo.php and URL/foo through the final location stanza.  If I replace the <code>$uri.php</code> in the <code>try_files</code> of the first stanza with <code>@php</code>, it should then use the <code>@php</code> location for URL/foo.</p>
  
  <p>For the <code>@php</code> location I have tried to set <code>SCRIPT_FILENAME</code> to:</p>
  
  <pre><code>     fastcgi_param SCRIPT_FILENAME "/usr/share/nginx/html$uri.php";
       fastcgi_param SCRIPT_FILENAME "$request_filename.php";
  </code></pre>
  
  <p>None of these have worked.</p>
  
  <p>In debugging this, no <code>add_header</code> line has ever emitted anything for URL/foo. The Content-Type is always set to application/octet-stream and, amusingly, it always manages to send back the content of the php file (it gets downloaded).</p>
  
  <p>I'm obviously doing something wrong, but I'm not seeing what.</p>