When I tried to install YOURLS, a short URL generator, on my Nginx based PHP server, I met a great many of problem. In those problems, the most bothering one was Nginx shows No Input File Specified.

When I first met this Error Code, definitely, I tried to find the solution on Google, there are pretty many results. Almost all of them says that it's the problem on fastcgi_param SCRIPT_NAME of Nginx default configuration file. Some of them say pretty well, like this. I'm not mean these articles are wrong, but the modifying of fastcgi_param SCRIPT_NAME do not solve my problem at all. So I guess maybe the problem is not Nginx? Yep, when I first tried to edit the php.ini file, I succeed.

OK, first let me describe my problem before.

Just after unzipped the YOURLS installation files, configured the DNS correctly, and simply copied the Nginx configuration for WordPress, I opened the YOURLS management page (index.php actually) in browser, I got No Input File Specified (there is a pretty strange problem I don't understand till now, that these "No Input File Specified" browse leave no log in Nginx error log).

The final solution was from this blog. It's so easy just to modify php.ini like this:

# Adding this line (very important):
fastcgi.impersonate = 1
# Uncomment these lines:
cgi.fix_pathinfo=1
cgi.force_redirect = 0 #Actually there is no this line in my `php.ini`, maybe due to the different version.

Then reload php-fpm, problem solved.

That's all.

标题:Nginx+PHP如何解决“NO INPUT FILE SPECIFIED”问题

既然是看到了中文的教程,索性用英文写一份,否则岂不是简单的转载了吗。

Q.E.D.