出现该错误有很多可能,有可能是root配置不对,有可能是fastcgi_param SCRIPT_FILENAME参数不对等。

而本人遇到的也是参数不对,但是是一个比较少人提及的问题,nginx版本不对。

之前在nginx/1.10.1 或者 nginx/1.12.2里面都是这么写该参数:

fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;

然后我最近一次在ubuntu装nginx/1.4.6 (Ubuntu)却不行,出现了File not found,按照其他人的经验配置也不行。

于是我写死了该目录:

fastcgi_param SCRIPT_FILENAME /var/www/abc$fastcgi_script_name;

其中/var/www/abc既是我的项目目录。

所以可能版本较新nginx/1.4.6 (Ubuntu) ,现在$document_root已经被摒弃或者改为其他表现方式,或者需要自己手动配置,暂时不得而知,还在研究中,先让项目跑起来再说。

server {
listen 80;
server_name localhost; #charset koi8-r;
#access_log /var/log/nginx/host.access.log main; location / {
root /vagrant_data;
index index.php index.html index.htm;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME /vagrant_data$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

---------------------
作者:stephen one
来源:CSDN
原文:https://blog.csdn.net/qq_39399594/article/details/82706968
版权声明:本文为博主原创文章,转载请附上博文链接!

在使用vagrant访问PHP文件是报错“file not found”,好像是最新的NGINX不能识别document_root,只能改为自己的项目目录/vagrant_data的更多相关文章

  1. java -- SSM配置完成后,能访问jsp文件不能访问html文件,报错解析

    SSM配置完成后,能访问jsp文件不能访问html文件,报错解析 在确保路径没有任何问题的,情况下,相同的页面,jsp能够正常访问,html却不能正常访问(404). 解决方法: 在web.xml中添 ...

  2. struts2 升级至2.3.32时访问页面报错 File "/struts-tags" not found

    Apache struts是美国阿帕奇(Apache)软件基金会负责维护的一个开源项目,是一套用于创建企业级Java Web 应用的开源MVC框架,主要提供两个版本框架产品: struts 1和str ...

  3. 数据库安装后无法访问且mysql重启报错的解决方法

    数据库安装后无法访问,mysql重启报错: 或报错:MySQL is running but PID file could not be found 解决方法: 第一种方法:看磁盘是否已满:df –h ...

  4. 【svn】在提交文件是报错:previous operation has not finished;run 'cleanup' if it was interrupted

    1.svn在提交文件是报错:previous operation has not finished;run 'cleanup' if it was interrupted2.原因,工作队列被占用,只需 ...

  5. centos7 安装nginx和php5.6.25遇到 无法访问php页面 报错file not found 问题解决

    php-fpm安装完成,nginx安装完成 netstap -ntl| 发下端口正常开启 iptables -L 返现9000端口已经开放 ps -aux|grep nginx 发下nginx进程正常 ...

  6. R.java 文件内报错:Underscores can only be used with source level 1.7 or greater。

    R.java 文件内报错:Underscores can only be used with source level 1.7 or greater 网上查找后得知是Android工程图片资源命名的问 ...

  7. 如何快速解决myeclipse中导入jquery文件的报错。

    如何快速解决myeclipse中导入jquery文件的报错. 解决: 选中错误的文件, 点击右键, 选中myeclipse,点击Exclude From Validation.

  8. Python读取CSV文件,报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 727: illegal multibyte sequence

    Python读取CSV文件,报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 727: illegal mul ...

  9. 导入文件 服务器报错,有可能是 开发时候是window 服务器是linux,两个系统的文件系统的/和\是相反的,要注意这块

    导入文件 服务器报错,有可能是 开发时候是window 服务器是linux,两个系统的文件系统的/和\是相反的,要注意这块

随机推荐

  1. nodejs实现邮件发送

    需要安装的node模块 nodemailer 新建项目目录 mail-test 进入这个项目里使用终端初始化package.json(npm init) 安装express和nodemailer并保存 ...

  2. 解决window 12 service 不能调用excel ,报"System.Runtime.InteropServices.COMException (0x800A03EC)

    Step1: 运行comexp.msc -32 注意因为excel 是32 位的,所以这里用的32位的操作, 如用64位的操作命令:dcomcnfg.exe,将找不到excel com 进入compo ...

  3. 查看flask中所有的路由信息(同时查看/设置允许的请求方式get、post)

    查看flask中所有的路由信息(同时查看/设置允许的请求方式get.post) # -*- coding: utf-8 -*- from flask import Flask app = Flask( ...

  4. MHA-结合MySQL半同步复制高可用集群(Centos7)

    目录 一.理论概述 本案例部署思路 二.环境 三.部署 部署MHA 部署二进制包MySQL及部署主从复制 部署半同步复制 配置MHA MHA测试 部署lvs+keepalived(lvs1,lvs2) ...

  5. 【Day5】3.反爬策略之模拟登录

    import urllib.request as ur import user_agent import lxml.etree as le request = ur.Request( url='htt ...

  6. pandas行转列、列转行、以及一行生成多行

    楔子 笔者曾经碰到过两种格式的数据,当时确实把我难住了,最后虽然解决了,但是方法不够优雅,而且效率也不高,如果想高效率,那么就必须使用pandas提供的方法.而pandas作为很强的一个库,一定可以优 ...

  7. 解决在Linux操作系统下无法连接MySQL服务端的问题

    遇到这种问题的时候我们需要考虑的是防火墙规则,因为防火墙默认是禁止所有端口访问的,所以我们需要添加一个访问端口来连接MySQL. 命令如下: 允许某端口   firewall-cmd  --zone= ...

  8. 04 Windows编程——Unicode

    VS 2017下源码 #include<stdio.h> int main() { char ASC_a = 'a'; char *ASC_str = "hello"; ...

  9. 02 WIndows编程——危险的sizeof

    C语言中,对 sizeof() 的处理都是在编译阶段进行. 下面代码,注意可变参数是怎么使用的 #include<Windows.h> #include<stdio.h> in ...

  10. 一个页面,WEB全功能

    当鼠标在页面上往下滑动的时候,页面也一直向下,标签也顺带着全部向下滑动 以前浏览页面,主要是在PC上进行浏览,一个页面不适于太长,需要用户向下拖动: 当时的设计是,点击标签,点击不同的标签,跳转到不同 ...