Nginx – php-fpm returning empty response to nginx

fastcginginxPHPphp-fpm

nginx is connecting to php-fpm over fastcgi, using the standard /etc/nginx/fastcgi_params in the location block.

When connecting to /.status (php-fpm.ini::ping.path) from the command line with cgi-fcgi -bind, the result comes back as expected (X-Powered-By set, response body, etc).

When requesting with nginx, the result comes back empty (X-Powered-By set, no body length or content). nginx returns 200, since it got a "valid" response.

Watching over tcpdump, I've isolated the requests to parity in their FCGI headers (minus user-related env variables still set by the shell.)

Best Answer

The standard factcgi_params file doesn't contain the key line for SCRIPT_FILENAME.

location ~ \.php$ {
                include fastcgi_params;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}

Add it and restart nginx.