在使用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,两个系统的文件系统的/和\是相反的,要注意这块
随机推荐
- SmartEvent with kbmMW #1
前言 前面的文章,我写了有关SmartBinding框架方面的内容.SmartBinding的目的是将数据容器绑定到一起,通常情况下,数据容器可以是显示数据或与数据交互的控件(Edit,ListVie ...
- 第五章、Celery分布式系统
Celery 官方 Celery 官网:http://www.celeryproject.org/ Celery 官方文档英文版:http://docs.celeryproject.org/en/la ...
- 怎么读取properties文件和ini文件?
一.读取properties文件: properties中的内容: server.ip = 127.0.0.1 server.port = 22 //原生java即可读取public static v ...
- springboot和Redis整合
springboot简化了许多的配置,大大提高了使用效率.下面介绍一下和Redis整合的一些注意事项. 首先介绍单机版的redis整合. 1.第一步当然是导入依赖 <dependency> ...
- 编译和执行 C# 应用程序
- FPGA学习笔记——点亮LED
软件平台:win7(64bit) + Quartus II 9.1 (64-Bit) 硬件平台:东理电子Easy-FPGA Cyclone II EP2C5T114C8N 这个开发板买了很长时间了,买 ...
- 07 Windows编程——窗口滚动条
两个函数:GetScrolnfo和SetScrollnfo一个结构:SCROLLINFO两个消息:WM_CREATE和WM_SIZE 滚动条结构体 typedef struct tagSCROLLIN ...
- linux 终端命令学习
Linux 的版本不同,其终端下命令也有所差异的. cal -y / -d /-m 查看日历的 free -m /df -m 查剩余空间的 passwd -l / -u 用户名 -锁定,解锁 ...
- Codeforces 1179 D - Fedor Runs for President
D - Fedor Runs for President 思路: 推出斜率优化公式后,会发现最优点只可能来自凸斜率中的第一个元素和最后一个元素, 这两个元素不用维护凸斜率也能知道,就是第一个和上一个元 ...
- Linux系统运维之修炼秘法
在这个现如今的互联网高速发展的时代,如何才能保持住一门铁的饭碗.无疑最稳妥的自然就是选择一门任何时代都不会落伍的技能,来选择深入学习研究.大家可能觉得这一期的Linux就该这么学的话题比较世俗.但是不 ...