在使用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,两个系统的文件系统的/和\是相反的,要注意这块
随机推荐
- mimikatz记录
mimikatz需要管理员权限运行 vps监听 nc -lvp 4444 服务器管理员权限执行 mimikatz.exe ""privilege::debug"" ...
- Image Processing and Analysis_8_Edge Detection:Edge and line oriented contour detection State of the art ——2011
此主要讨论图像处理与分析.虽然计算机视觉部分的有些内容比如特 征提取等也可以归结到图像分析中来,但鉴于它们与计算机视觉的紧密联系,以 及它们的出处,没有把它们纳入到图像处理与分析中来.同样,这里面也有 ...
- storedownloadd占用cpu高
禁用App Store的自动更新
- Django drf:视图层封装、ViewSetMixin、路由配置、解析器、响应器
一.视图层封装 二.ViewSetMixin 三.路由配置 四.解析器 五.响应器 一.视图层封装 1.基本视图 写一个出版社的增删改查resfull接口 路由: url(r'^publish/$', ...
- oss打包下载
private static final String OSS_ENDPOINT = PropertiesUtil.getString("oss.endpoint"); priva ...
- jquery中prop,attr,data的区别
这两天翻了jq的源码,今天看到了jq关于数据存储的几个方法,遂总结一下,和小伙伴没分享一下,哪里说的不对,还望批评指正~~~ 废话不多说,直接上代码: $(function(){ $('#div1') ...
- Mysql读写分离 及高可用高性能负载均衡实现
什么是读写分离,说白了就是mysql服务器读的操作和写的操作是分开的,当然这个需要两台服务器,master负责写,slave负责读,当然我们可以使用多个slave,这样我们也实现了简单意义上的高可用和 ...
- 修改HTTPS加密协议TLS1.0为TLS1.2
一:首先为什么要改为TLS1.2 因为各大浏览器相继发布声明将停止支持 TLS 1.0 和 TLS 1.1 https://www.cnblogs.com/jpush88/p/9846047.html ...
- 甘特图、Data Editors控件新玩法—DevExpress WPF v19.2
通过DevExpress WPF Controls,你能创建有着强大互动功能的XAML基础应用程序,这些应用程序专注于当代客户的需求和构建未来新一代支持触摸的解决方案. 无论是Office办公软件的衍 ...
- C# LINQ标准查询操作符
首先添加数据集合 [Serializable] public class Racer : IComparable<Racer>, IFormattable { public Racer() ...