Nginx: Resolving “No input file specified” error

If you are using nginx with php-cgi and have followed the standard procedure to set it up, you might often get the “No input file specified.” error. What happens here is that, when nginx receives the request to serve a non-existent php file, it passes the request to php-cgi. Php-cgi, while trying to processs the request, finds that the php file does not exist at all. Hence it sends a “No input file specified.” message with a “404 Not Found” header.

Although, it’s not technically an error, we can catch the request for the non-existent php file and show a custom 404 page.