在使用vagrant访问PHP文件是报错“file not found”,好像是最新的NGINX不能识别document_root,只能改为自己的项目目录/vagrant_data
出现该错误有很多可能,有可能是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的更多相关文章
- java -- SSM配置完成后,能访问jsp文件不能访问html文件,报错解析
SSM配置完成后,能访问jsp文件不能访问html文件,报错解析 在确保路径没有任何问题的,情况下,相同的页面,jsp能够正常访问,html却不能正常访问(404). 解决方法: 在web.xml中添 ...
- struts2 升级至2.3.32时访问页面报错 File "/struts-tags" not found
Apache struts是美国阿帕奇(Apache)软件基金会负责维护的一个开源项目,是一套用于创建企业级Java Web 应用的开源MVC框架,主要提供两个版本框架产品: struts 1和str ...
- 数据库安装后无法访问且mysql重启报错的解决方法
数据库安装后无法访问,mysql重启报错: 或报错:MySQL is running but PID file could not be found 解决方法: 第一种方法:看磁盘是否已满:df –h ...
- 【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.原因,工作队列被占用,只需 ...
- centos7 安装nginx和php5.6.25遇到 无法访问php页面 报错file not found 问题解决
php-fpm安装完成,nginx安装完成 netstap -ntl| 发下端口正常开启 iptables -L 返现9000端口已经开放 ps -aux|grep nginx 发下nginx进程正常 ...
- 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工程图片资源命名的问 ...
- 如何快速解决myeclipse中导入jquery文件的报错。
如何快速解决myeclipse中导入jquery文件的报错. 解决: 选中错误的文件, 点击右键, 选中myeclipse,点击Exclude From Validation.
- 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 ...
- 导入文件 服务器报错,有可能是 开发时候是window 服务器是linux,两个系统的文件系统的/和\是相反的,要注意这块
导入文件 服务器报错,有可能是 开发时候是window 服务器是linux,两个系统的文件系统的/和\是相反的,要注意这块
随机推荐
- TypeScript入门七:TypeScript的枚举
关于枚举 数字枚举 字符串枚举 异构枚举 计算的和常量成员 运行时的枚举与反向映射 常量枚举与外部枚举 一.关于枚举 枚举:一个集的枚举是列出某些有穷序列集的所有成员的程序,或者是一种特定类型对象的计 ...
- ccs编译.lib
新建 New一个CCS Project Output type选择"Static Library" 添加源文件 右击工程 -> Add Files- 编译 编译生成的.lib ...
- [LeetCode] 206. Reverse Linked List ☆(反转链表)
Reverse Linked List 描述 反转一个单链表. 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->3-> ...
- Cannot determine value type from string 'xxxxxx'
Cannot determine value type from string 'xxxxxx' 查了一下,意思就是字段和属性名没有对上. 反复查看代码,字段名和属性名一致. 最后翻阅资料得知是因为构 ...
- 剑指Offer编程题(python)——二叉树
1.重建二叉树 """ 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树.假设输入的前序遍历和中序遍历的结果中都不含重复的数字. 例如输入前序遍历序列{1,2,4 ...
- SVN将项目代码加入svn版本控制
将已有项目代码加入svn版本控制 - TortoiseSVN入门篇Windows下SVN实用教程(以TortoiseSVN作为客户端(client)) 翻译: Bravo Young Next: 版本 ...
- maven的一些命令以及说明 ——1
mvn compile : 编译源文件 mvn test-compile : 编译Junit测试文件 mvn test : 运行junit测试文件 mvn package : 编译 + 测试 ...
- PrintWriter返回乱码的分析及解决
用response得到输出流,即response.getOuptStream(); 返回值为ServletOutputStream 对象,即JSP的out对象,要么用response得到输出对象Pri ...
- OpenCV VideoCapture.get()参数详解
转自https://blog.csdn.net/u011436429/article/details/80604590 方便查阅
- 开启树莓派自带的VNC功能
前期准备 树莓派可以连接路由器或连上wifi,我用的是自己的小米路由器,目的是为了获取内网IP 工具准备 下载 vnc viewer https://www.realvnc.com/en/connec ...