/var/www/nginx-default中放上一份phpinfo.php,使用http://localhost/phpinfo.info 访问,结果报错,显示 “No input file specified”

在ubuntu系统中,使用apt-get install nginx和php-cgi,配置好nginx和php。

在/var/www/nginx-default中放上一份phpinfo.php,使用
http://localhost/phpinfo.info
访问,结果报错,显示 “No input file specified”

现存的各种方案,是让你把nginx站点配置文件中的这一句话hardcode起来的(真想骂人):
# 即把fastcgi_param指令的SCRIPT_FILENAME项 从动态值改为fixed值,如:
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
# 修改为
fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default$fastcgi_script_name;
另外还有一种是修改php.ini中的什么
cgi.fix_pathinfo=1
doc_root=
请注意!!以上这些都是非常不良的改动!

问题原因
导致“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。

备注:以上修改方法,供大家学习参考,请针对自己当前运行的nginx版本,采取必要措施。你懂的。

Nginx执行php显示no input file specified的处理方法的更多相关文章

  1. js获取input file完整路径的方法

    function getPath(){  //判断浏览器  var Sys = {};  var obj = document.getElementById("headImg"); ...

  2. No input file specified的解决方法apache伪静态

    http://jingyan.baidu.com/article/dca1fa6f8d623ff1a44052e8.html (一)IIS Noinput file specified 方法一:改PH ...

  3. 地址重写 No input file specified的解决方法

    转载自:http://blog.csdn.net/williamsblog/article/details/37532737 (一)IIS Noinput file specified 方法一:改PH ...

  4. No input file specified的解决方法

    (一)IIS Noinput file specified 方法一:改PHP.ini中的doc_root行,打开ini文件注释掉此行,然后重启IIS 方法二:请修改php.ini找到; cgi.for ...

  5. 提示No input file specified的解决方法

    (一)IIS Noinput file specified 方法一:改PHP.ini中的doc_root行,打开ini文件注释掉此行,然后重启IIS 方法二: 请修改php.ini 找到 ; cgi. ...

  6. ThinkPHP 的URL重写时遇到No input file specified的解决方法

    因为在Fastcgi模式下,php不支持rewrite的目标网址的PATH_INFO的解析 ThinkPHP运行在URL_MODEL=2时,会出现 No input file specified.的情 ...

  7. ThinkPHP的URL重写时遇到No input file specified的解决方法

    因为在Fastcgi模式下,php不支持rewrite的目标网址的PATH_INFO的解析 ThinkPHP运行在URL_MODEL=2时,会出现 No input file specified.的情 ...

  8. ThinkPHP隐藏index.php出现No input file specified的解决方法

    因为在Fastcgi模式下,php不支持rewrite的目标网址的PATH_INFO的解析 ThinkPHP运行在URL_MODEL=2时,会出现 No input file specified.的情 ...

  9. phpstudy5.6 No input file specified的解决方法

    一.问题描述 5.6就提示这个错误,切换5.5就可以 二.原因分析 原因1:提示:“No input file specified.”原因在于使用的PHP5.6是fast_cgi模式,而在某些情况下, ...

随机推荐

  1. IOS—UITextFiled控件详解

    IOS—UITextFiled控件详解 //初始化textfield并设置位置及大小 UITextField *text = [[UITextField alloc]initWithFrame:CGR ...

  2. ACM: 限时训练题解- Travelling Salesman-最小生成树

    Travelling Salesman   After leaving Yemen, Bahosain now works as a salesman in Jordan. He spends mos ...

  3. bzoj 1217 [HNOI2003]消防局的设立 Label:图论

    题目描述 2020年,人类在火星上建立了一个庞大的基地群,总共有n个基地.起初为了节约材料,人类只修建了n-1条道路来连接这些基地,并且每两个基地都能够通过道路到达,所以所有的基地形成了一个巨大的树状 ...

  4. 【BZOJ】2693: jzptab

    http://www.lydsy.com/JudgeOnline/problem.php?id=2693 题意:求$\sum_{i=1}^{n} \sum_{j=1}^{m} lcm(i, j)$, ...

  5. POJ 1654 Area(水题)

    题目链接 卡了一下精度和内存. #include <cstdio> #include <cstring> #include <string> #include &l ...

  6. unix network programming volume1 sorce code build and get(UNIX網絡編程卷1第三版)

    source code下载地址:unpv13e.tar.gz下载 (也有放一份在google cloud storage) compile 1. ./configure 2. cd lib make ...

  7. Spring MVC过滤器-字符集过滤器(CharacterEncodingFilter)

    spring的字符集过滤通过用于处理项目中的乱码问题,该过滤器位于org.springframework.web.filter包中,指向类CharacterEncodingFilter,Charact ...

  8. 几种常用的JS类定义方法

    几种常用的JS类定义方法   // 方法1 对象直接量var obj1 = {    v1 : "",    get_v1 : function() {        return ...

  9. hdu 1312

    原题链接 题意:“@”为起点,“.”为路,求可以走的格子有多少个(包括起点) 水题 bfs搜一发 思路:只有可以走的节点才能进入队列,所以每次出队列时ans+1就可以了(没有退出条件,所有可进入的节点 ...

  10. java笔记随笔

    基本语法 编写Java程序时,应注意以下几点: 大小写敏感:Java是大小写敏感的,这就意味着标识符Hello与hello是不同的. 类名:对于所有的类来说,类名的首字母应该大写.如果类名由若干单词组 ...