Solution
http://www.blog.163.com/cobyeah@126/blog/static/140137653201142945054441/
问题原因
导致“No input file specified. ”这个问题的原因,是因为nginx的配置不正确,从而导致CGI获取参数错误。 简单来说,是因为$document_root这个变量尚未定义。
Nginx的配置文件中,
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
是一个写在location块(通常是匹配php)中的指令语句。 而我们也知道,在nginx中,有三级的关系,http > server > location。 如果要在location块中使用$document_root,需要在上层server块或http块中定义了root指令,这样才能通过继承关系,在location块中用$document_root拿到root的值。而定义在别的location块中的root指令的值,是一个局部变量,其值无法在匹配php的这个location块中被获取。
解决方法
解决这个问题的办法,是把”/” location块中的root上提到server。 或者,在php的location块中,重新定义root。
php 站配置参考
fastcgi启动命令
spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi
#ubuntu自动启动
nginx配置
server {
listen 80;
server_name test.anasit.com;
root /var/www/test;
access_log /var/log/nginx/test.access.log;
location / {
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/test;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
作者:ryanemax
微信关注:ryanemax (刘雨飏)
本文出处:https://romantic-hoover-f991f1.netlify.com/faq/lnmp/nginx-php-nofiles/
授权协议:
CC BY-SA 4.0