title: FPM/Nginx: unable to open primary script
body: <p>I'm struggling to get NGINX and PHP-FPM to talk effectively. My NGINX configuration file includes the following definition for the <code>api</code> offset:</p>
  
  <pre><code>    location /api {
          try_files $uri /api/index.php$is_args$args;
          gzip    off;
          fastcgi_pass    PHP:9000;
          fastcgi_index   index.php;
          fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
          fastcgi_keep_conn off; 
          include         fastcgi_params;
      }
  </code></pre>
  
  <p>and on my PHP machine I have the following Pool configuration:</p>
  
  <pre><code>[api]
  listen = 9000
  user = www-data
  group = www-data
  pm = dynamic
  pm.max_children = 10
  pm.start_servers = 3
  pm.min_spare_servers = 2
  pm.max_spare_servers = 5
  pm.status_path = /status
  </code></pre>
  
  <p>I then tail the NGINX server's log file and when hitting the webserver with:</p>
  
  <pre><code>http://localhost/api
  # or 
  http://localhost/api/index.php
  # or ...
  http://localhost/api/resources.json
  </code></pre>
  
  <p>I can see from the NGINX server log that NGINX is correctly matching the <code>/api</code> pattern but i get the following errors:</p>
  
  <blockquote>
    <p>[error] 14#0: *1 FastCGI sent in stderr: "Unable to open primary script: /app/html/websites/couchbase/api/index.php (No such file or directory)"</p>
  </blockquote>
  
  <p>Where the root directory on the PHP machine is <code>/app/html/websites/couchbase</code>. I'm at a complete loss on what this error really means or more importantly how to debug it from here. Any help would be greatly appreciated.</p>
  
  <p>p.s. I have tried replacing <code>$document_root</code> reference in the fast_cgi_param to hard coded values to see if it makes a difference. It does in the sense that if I point it at an incorrect directory it gives me 
  a <code>No input file specified.</code> error. The only place where I get the error is when it seemingly is pointed to the right place. </p>
  
  <hr>
  
  <p>Added this in case it helps clarify ... this is the file system at <code>/app/html/websites/couchbase/api</code> on the PHP/FPM machine.</p>
  
  <p><img src="https://i.stack.imgur.com/feGeZ.png" alt="filesystem"></p>
  
  <p>I created the <code>test.php</code> file which basically just echo's "Ok" back but that works no better than the primary goal of running <code>index.php</code>.</p>
  
  <blockquote>
    <p>note: I wasn't sure if execution permissions were important -- as you can see <code>test.php</code> does not have them set in the picture -- but I've tried them both ways and it appears to make no difference.</p>
  </blockquote>