Nginx执行php显示no input file specified的处理方法
/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的处理方法的更多相关文章
- js获取input file完整路径的方法
function getPath(){ //判断浏览器 var Sys = {}; var obj = document.getElementById("headImg"); ...
- No input file specified的解决方法apache伪静态
http://jingyan.baidu.com/article/dca1fa6f8d623ff1a44052e8.html (一)IIS Noinput file specified 方法一:改PH ...
- 地址重写 No input file specified的解决方法
转载自:http://blog.csdn.net/williamsblog/article/details/37532737 (一)IIS Noinput file specified 方法一:改PH ...
- No input file specified的解决方法
(一)IIS Noinput file specified 方法一:改PHP.ini中的doc_root行,打开ini文件注释掉此行,然后重启IIS 方法二:请修改php.ini找到; cgi.for ...
- 提示No input file specified的解决方法
(一)IIS Noinput file specified 方法一:改PHP.ini中的doc_root行,打开ini文件注释掉此行,然后重启IIS 方法二: 请修改php.ini 找到 ; cgi. ...
- ThinkPHP 的URL重写时遇到No input file specified的解决方法
因为在Fastcgi模式下,php不支持rewrite的目标网址的PATH_INFO的解析 ThinkPHP运行在URL_MODEL=2时,会出现 No input file specified.的情 ...
- ThinkPHP的URL重写时遇到No input file specified的解决方法
因为在Fastcgi模式下,php不支持rewrite的目标网址的PATH_INFO的解析 ThinkPHP运行在URL_MODEL=2时,会出现 No input file specified.的情 ...
- ThinkPHP隐藏index.php出现No input file specified的解决方法
因为在Fastcgi模式下,php不支持rewrite的目标网址的PATH_INFO的解析 ThinkPHP运行在URL_MODEL=2时,会出现 No input file specified.的情 ...
- phpstudy5.6 No input file specified的解决方法
一.问题描述 5.6就提示这个错误,切换5.5就可以 二.原因分析 原因1:提示:“No input file specified.”原因在于使用的PHP5.6是fast_cgi模式,而在某些情况下, ...
随机推荐
- 优先使用最新版本的IE 和 Chrome 内核 1 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
兼容模式 优先使用最新版本的IE 和 Chrome 内核 1 <meta http-equiv="X-UA-Compatible" content="IE=edge ...
- 安装lua_zlib让OpenResy可以接收gzip请求
1.下载和安装lua_zlib wget https://github.com/brimworks/lua-zlib/archive/master.zip unzip master.zip cd lu ...
- ios cocos2d 画线出现闪烁问题
根据http://www.merowing.info/2012/04/drawing-smooth-lines-with-cocos2d-ios-inspired-by-paper/ 用cocos2d ...
- js小效果-简易计算器
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...
- ThinkPHP随笔
使用应用分组模式开发程序时,U函数表示地址时,要用这种格式 “项目名/控制器名/方法名”写地址,不能直接使用U("handle") 如:var handleUrl = '{:U(& ...
- osg学习示例之遇到问题四骨骼动画编译osgCal
osg学习示例之遇到问题四骨骼动画编译osgCal 转自:http://blog.csdn.net/wuwangrun/article/details/8239451 今天学到书<OpenSce ...
- python基础学习二——第二天
对于python而言,一切事物都是对象,对象是基于类创建的,对象继承了类的属性,方法等特性 一.int 首先我们来查看一下int包含了哪些函数 # python3.x dir(int) # ['__a ...
- iOS容易造成循环引用的三种场景
iOS容易造成循环引用的三种场景 ARC已经出来很久了,自动释放内存的确很方便,但是并非绝对安全绝对不会产生内存泄露.导致iOS对象无法按预期释放的一个无形杀手是--循环引用.循环引用可以简单理解为 ...
- 继承(JAVA)
继承是面向对象最显著的一个特性.继承是从已有的类中派生出新的类,新的类能吸收已有类的数据属性和行为,并能扩展新的能力. 一.继承的基本语法: 在Java语言中,用extends关键字表示一个类继承了另 ...
- android-发送短信