I'm struggling to get NGINX and PHP-FPM to talk effectively. My NGINX configuration file includes the following definition for the api
offset:
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;
}
and on my PHP machine I have the following Pool configuration:
[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
I then tail the NGINX server's log file and when hitting the webserver with:
http://localhost/api
# or
http://localhost/api/index.php
# or ...
http://localhost/api/resources.json
I can see from the NGINX server log that NGINX is correctly matching the /api
pattern but i get the following errors:
[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)"
Where the root directory on the PHP machine is /app/html/websites/couchbase
. 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.s. I have tried replacing $document_root
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 No input file specified.
error. The only place where I get the error is when it seemingly is pointed to the right place.
Added this in case it helps clarify ... this is the file system at /app/html/websites/couchbase/api
on the PHP/FPM machine.
I created the test.php
file which basically just echo's "Ok" back but that works no better than the primary goal of running index.php
.
note: I wasn't sure if execution permissions were important -- as you can see
test.php
does not have them set in the picture -- but I've tried them both ways and it appears to make no difference.