在lnmp上调试php项目,之前已经在上面测试过tp5框架,可以正常访问。但新项目由于项目中有些路径是写固定路径的。为了不去修改代码。配置新项目的时候,为新项目设置新的目录。问题就出现了,网页提示  no input file specified。nginx 的error_log 中显示Operation not permitted in Unknown on line 0  Unable to open primary script:检查nginx中的server配置,确认root配置确实是项目所在目录,而且之前的tp5框架所在目录可以正常访问。百度搜索了很多答案,试了都不行。最后问题解决了,是open_basedir设置的问题,导致php没有权限读取新项目目录。解决思路访问php文件   nginx 服务器提示这个错误,具体原因有多种。nginx 或者php fastcgi进程无法找到访问的php文件。
要快速找出具体原因,进行一些设置。
php.ini 开启错误记录。
error_reporting = E_ALL
display_errors = On
og_errors = On
error_log = /www/logs/php_error.log

nginx.conf 配置中开启  error_log    /home/wwwlogs/nginx_error.log  info;   
info 表示开启详细的nginx服务器错误提示。
可以打开这个文件看到具体的错误信息。

具体原因主要两种,
第一,保证nginx中的 server块配置 
server_name  example.com;
root   /opt/webroot;
监听的域名和域名对应的网站根目录和项目实际目录要对应

第二是  open_basedir  的设置限制了php进程不能读取open_basedir 设置的目录之外的文件。这个设置是为了服务器安全。
open_basedir 在php.ini   和nginx中都可以配置。

在nginx中的配置格式(这个是lnmp环境中的fastcgi.conf中的配置)
fastcgi_param PHP_ADMIN_VALUE “open_basedir=/opt/webroot:/tmp/:/proc/”;

: 冒号是路径的分割符。上面配置代表了open_basedir包含三个目录。/opt/webroot 代表webroot目录及其根目录 ,路径后有斜杠  /proc/ 表示只能访问 /proc目录,不能访问子目录。
还可以针对一个项目在项目的document_root 下面创建一个 .user.ini  文件,配置当前项目的open_basedir
.
文件中写上这样一句话
open_basedir=/home/wwwroot/default:/tmp/:/proc/

在php.ini中配置  在前面加分号,将它注释掉。
;open_basedir =

另外在nginx.conf 中 ( 有时候独立出来在fastcgi.conf中)
fastcgi_param   SCRIPT_FILENAME documentrootdocument_rootdocumentr​ootfastcgi_script_name;

配置语句之前,要先有$document_root 的定义
$document_root  代表是就是 
server_name  example.com;

root  /webroot;
index index.php;
中root定义的项目根目录

另外检查一些,项目目录权限,nginx或php进程是否有权限读取目录,通过chmod 或chown修改文件权限。

转自 http://www.nocome.com/thread-33300-1-1.html

nginx出现No input file specified.的更多相关文章

  1. 解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办

    解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办 问题是出现在了PHP.INI上面了 ,原 ...

  2. 【LNMP】提示Nginx PHP “No input file specified”错误的解决办法

    原理: 任何对.php文件的请求,都简单地交给php-cgi去处理,但没有验证该php文件是否存在. PHP文件不存在,没办法返回普通的404错误,它返回 一个404,并带上一句”No input f ...

  3. Nginx+PHP “No input file specified”错误的解决办法

    配置官网商城php网站时候,界面报错“No input file specified” 原理: 任何对.php文件的请求,都简单地交给php-cgi去处理,但没有验证该php文件是否存在. PHP文件 ...

  4. nginx php No input file specified 怎样处理?

    配置nginx支持php 出现了No input file specified ? 仅仅要改动下安装文件夹下的  nginx.conf下的 location ~ \.php$ {           ...

  5. Nginx报 No input file specified. 的问题解决之路 转

    https://m.aliyun.com/yunqi/articles/34240 今天接手公司的一个项目,照例将项目clone下来,配置本地host,nginx,然后访问. 怎么回事?迅速在php的 ...

  6. nginx提示No input file specified怎么办

    用了网上提供的各种方法都不行,即便html能正常打开,php文件依然有问题.而后继续尝试了修改权限 chown -vR www:www /folder 功能都正常. nginx.conf 的 user ...

  7. nginx下No input file specified错误的解决

    在web服务的根目录下创建 .htaccess文件,设置一下内容: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond % ...

  8. 完美解决 nginx No input file specified.

    一次开发中遇到了这个问题:No input file specified nginx版本1.8 找遍网络都是说 fastcgi_param SCRIPT_FILENAME $document_root ...

  9. Nginx执行php显示no input file specified的处理方法

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

随机推荐

  1. ACM-Maximum Tape Utilization Ratio

    题目描述:Maximum Tape Utilization Ratio Tags: 贪婪策略 设有n 个程序{1,2,…, n }要存放在长度为L的磁带上.程序i存放在磁带上的长度是li ,1 < ...

  2. SecureCRT打开文件中文乱码

    1.菜单:option(选项): 2.选择session options(会话选项): 3.打开的窗口中,点击Appearance(外观): 4.页面上:character encoding(字符编码 ...

  3. 尝试用kotlin做一个app(五)

    JSP后台管理系统 开发工具是IntelliJ IDEA+tomcat+mysql5.6.19+mysql-connector-java-5.1.48.jar+easyui+kindeditor 之前 ...

  4. python阴阳鱼绘制(使用turtle)

    from turtle import * def draw(radius ,color1 , color2): #设置画笔的大小 width(3) #设置画笔颜色和填充颜色 color("b ...

  5. stm32f4 dma + uart idle + double 调试小记

    使用 stm32f4 调试uart 接收, 使用 空闲中断,dma 双缓冲模式,有以下几点需要注意的. 调试的时候断点不要打在 if (USART_GetITStatus(USART6, USART_ ...

  6. python中__str__与__repr__

    (1)背景 python中,对于类(自定义类)的实例对象的默认显示既没有太大用处,也不美观.比如: class adder: def __init__(self,value=0): self.data ...

  7. LeetCode刷题笔记(1-9)

    LeetCode1-9 本文更多是作为一个习题笔记,没有太多讲解 1.两数之和 题目请点击链接 ↑ 最先想到暴力解法,直接双循环,但是这样复杂度为n平方 public int[] twoSum(int ...

  8. 每天一点点之vue框架开发 - vue坑-This relative module was not found

    94% asset optimization ERROR Failed to compile with 1 errors This relative module was not found: * . ...

  9. VC++ DLL 2 静态链接库

    这一篇以VS2013为例子介绍怎样编写一个静态链接库和调用. 1.打开VS2013,新建Visual C++ 的win32项目: 新建后工程分支如下: 添加头文件和源文件: 编写头文件和源文件内容: ...

  10. win10编译jpeglib

    jpeglib看名字都大概知道和图像格式jpg或jpeg有关了,是一个常用的图像处理软件都会依赖的开源库. 首先去官网下载jpeglib的源码,直接取这里下载:http://www.ijg.org/f ...