在使用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,两个系统的文件系统的/和\是相反的,要注意这块
随机推荐
- # marshalsec使用
开启rmi服务,恶意类放到服务上 D:\jdk_1.8\bin\java.exe -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.RMIRe ...
- linux服务器忘记密码操作
当重启镜像时候 看到这个界面的时候 按1 按1之后进入如下界面 红色区域有解释 按e是编译模式,我们按e OK 这里我们选择第二行按b 进入开发者模式,然后等待启动 然后更改密码
- 【Zookeeper】集群环境搭建
一.概述 1.1 Zookeeper的角色 1.2 Zookeeper的读写机制 1.3 Zookeeper的保证 1.4 Zookeeper节点数据操作流程 二.Zookeeper 集群环境搭建 2 ...
- python读txt数据报编码错误
读数据代码: with open(path,'r') as f: for line in f: line = line.strip() 报错: UnicodeDecodeError: 'gbk' co ...
- Const *ptr ptr
1. const int *ptr = NULL; <=> int const *ptr = NULL; 1) 表示指向符号常量的指针变量,指针变量本身并非const所以可以指向其他变量. ...
- 向量的一种特殊乘法 element wise multiplication
向量的一种特殊乘法 element wise multiplication 物体反射颜色的计算采用这样的模型: vec3 reflectionColor = objColor * lightColor ...
- cmake升级3.6
https://blog.csdn.net/u013714645/article/details/77002555 ./boostrap gmake gmake install
- Python 常用的ORM框架简介
ORM概念ORM(Object Ralational Mapping,对象关系映射)用来把对象模型表示的对象映射到基于S Q L 的关系模型数据库结构中去.这样,我们在具体的操作实体对象的时候,就不需 ...
- 大数据之路week05--day02(Maven安装,环境变量的配置及基本使用)
今天我们就来学习一下maven,怎么说呢,maven更像是一种管理的工具,实现的原理是使用插件. 举个例子,比如说,一个公司需要做一个项目,这个项目又分成了很多的模块,每个模块又分成了许多的业务等等, ...
- Spring-使用注解开发
8.使用注解开发 在Spring4之后,要使用注解开发,必须要保证AOP包已经导入了 使用注解需要导入context约束,增加注解的支持! <?xml version="1.0&quo ...