nginx出现No input file specified.
在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_rootdocumentrootfastcgi_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.的更多相关文章
- 解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办
解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办 问题是出现在了PHP.INI上面了 ,原 ...
- 【LNMP】提示Nginx PHP “No input file specified”错误的解决办法
原理: 任何对.php文件的请求,都简单地交给php-cgi去处理,但没有验证该php文件是否存在. PHP文件不存在,没办法返回普通的404错误,它返回 一个404,并带上一句”No input f ...
- Nginx+PHP “No input file specified”错误的解决办法
配置官网商城php网站时候,界面报错“No input file specified” 原理: 任何对.php文件的请求,都简单地交给php-cgi去处理,但没有验证该php文件是否存在. PHP文件 ...
- nginx php No input file specified 怎样处理?
配置nginx支持php 出现了No input file specified ? 仅仅要改动下安装文件夹下的 nginx.conf下的 location ~ \.php$ { ...
- Nginx报 No input file specified. 的问题解决之路 转
https://m.aliyun.com/yunqi/articles/34240 今天接手公司的一个项目,照例将项目clone下来,配置本地host,nginx,然后访问. 怎么回事?迅速在php的 ...
- nginx提示No input file specified怎么办
用了网上提供的各种方法都不行,即便html能正常打开,php文件依然有问题.而后继续尝试了修改权限 chown -vR www:www /folder 功能都正常. nginx.conf 的 user ...
- nginx下No input file specified错误的解决
在web服务的根目录下创建 .htaccess文件,设置一下内容: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond % ...
- 完美解决 nginx No input file specified.
一次开发中遇到了这个问题:No input file specified nginx版本1.8 找遍网络都是说 fastcgi_param SCRIPT_FILENAME $document_root ...
- Nginx执行php显示no input file specified的处理方法
/var/www/nginx-default中放上一份phpinfo.php,使用http://localhost/phpinfo.info 访问,结果报错,显示 “No input file spe ...
随机推荐
- ACM-DFS Template
自己写的DFSTemplate: // DFS_Template.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" //DFS的思想是:一直向 ...
- Java JDK for Windows
目录 JDK简介下载安装配置JAVA_HOME和Path测试禁止Java自动更新(可选操作) JDK简介 JDK是Java语言的软件开发工具包,主要用于移动设备.嵌入式设备上的java应用程序.JDK ...
- RPC——看这一篇就…显然不够
引言 RPC blablabla…… RPC 知识点 扩展 有给老婆解释的如:https://www.jianshu.com/p/2accc2840a1b
- java课程课后作业190612之Beta版总结会议
1.每个成员在beta 阶段的实践和alpha 阶段有何改进? 陈阳:在编程的时候学习广播知识,了解了Android的广播机制完成了上课静音以及课前提醒的功能,在代码的美观上也有了一定的提升 2. 团 ...
- LeetCode 124. Binary Tree Maximum Path Sum 二叉树中的最大路径和 (C++/Java)
题目: Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as ...
- INSTALL_FAILED_SHARED_USER_INCOMPATIBLE错误解决
Target device: smartisan-yq601-3fa1a5dcInstalling APK: /Users/wangliang/workspace/emm-android/build/ ...
- 尝试用kotlin做一个app(二)
导航条 我想实现的效果是这样的 类似于ViewPager的效果,子类导航页面可以滑动,当滑动某个子类导航页面,导航线会平滑地向父类导航移动 ·添加布局 <!--导航分类:编程语言/技术文档/源码 ...
- cf1200 E Compress Words(哈希)
题意 有n个字符串,记为s1,s2……sn,s2与s1合并,合并的方式为:s1的后缀若与s2的前缀相同,就可以重叠起来,要最长的. 举个例子: “1333” “33345” → “133345” s ...
- 1.3 this深度面试题
var big = "1" var obj = { big: "2", showBig: function() { return this.big }, } o ...
- @Autowired注解与@Resource注解的区别(详细)
相信对现在Java码农来说,@Autowired跟@Resource并不陌生,二者都可以自动注入,但是两者的区别很多时候并没有被注意到. 一.注解的出处 @Autowired是Spring提供的注解, ...