/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. Leetcode Sqrt(x)

    参考Babylonian method  (x0  越接近S的平方根越好) class Solution { public: int sqrt(double x) { ) ; , tolerance ...

  2. 学习js正则表达式

    function UrlRegEx(url) { //如果加上/g参数,那么只返回$0匹配.也就是说arr.length = 0 var re = /(\w+):\/\/([^\:|\/]+)(\:\ ...

  3. 【hdu2795】Billboard

    Problem Description At the entrance to the university, there is a huge rectangular billboard of size ...

  4. Android --自定义简单Toast

    1. 效果图

  5. Android -- 重设字符并统计原字符以及修改字符的长度以及位置

    1. 效果图

  6. 编码Q&A

    Q:什么是编码? A:由于计算机中所有数据都是以二进制存在,那么为了存储数字,字母,各种符号和文字,计算机必须用一套映射系统来对应.比如我在某台计算机上规定,用00010001这个二进制数表示字母a, ...

  7. java画图程序_图片用字母画出来_源码发布

    在之前写了一篇blog:java画图程序_图片用字母画出来 主要是把一些调试的截图发布出来,现在程序调试我认为可以了(当然,你如果还想调试的话,也可以下载源码自己调试). 就把源码发布出来. 项目结构 ...

  8. 纪念逝去的岁月——C/C++交换排序

    交换排序 代码 #include <stdio.h> void printList(int iList[], int iLen) { ; ; i < iLen; i++) { pri ...

  9. C#常用方法二

    public sealed class StringTool { /// <summary> /// 将txt文件读入字符串 /// </summary> /// <pa ...

  10. Hadoop.2.x_HA部署

    一.概念与HA思路 1. 首先Hadoop架构为主从架构(NameNode/DataNode) 2. NameNode管理着文件系统和与维护客户端访问DataNode 3. Hadoop 2.0 之前 ...