全部
常见问题
产品动态
精选推荐

failed to open stream: No such file or directory问题解决大全

管理 管理 编辑 删除

这篇文章主要为大家详细介绍了failed to open stream: No such file or directory问题解决大全,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,有需要的朋友可以收藏方便以后借鉴。

failed to open stream: No such file or directory是PHP站点经常可能会遇到的问题,361源码做了个总结,希望能帮助到一些遇到这个问题的朋友们。

案例一

(failed to open stream: No such file or directory)在IIS下PHP环境配置的目录权限导致出错的问题

原因及解决方法

配置环境为 IIS + php

如果确认你的程序在其他环境下下可以正常运行而唯独在Win 下的 IIS 出现类似如下的错误:

Warning: main(./Config.php): failed to open stream: No such file or directory in D:/wwwroot/Demo/Config.php on line 13

Fatal error: main(): Failed opening required './Config.php' (include_path='.;c:/php4/pear') in D:/wwwroot/Core/Config.php on line 13

这个问题主要是 由于Win NTFS盘下去除了everyone 权限引起的, 在安全权限中加个 Internet 来宾账号就解决了.

操作步骤: D盘 -> 属性 -> 安全 -> 添加 用户 IUSR_XXXXX OK

案例二

问题就是:

Warning: require_once(../lib/DBUtil.class.php) [function.require-once]: failed to open stream: No such file or directory in E:/phppro/dxh/service/ExpertService.class.php on line 2

Fatal error: require_once() [function.require]: Failed opening required '../lib/DBUtil.class.php' (include_path='.;C:/php5/pear') in E:/phppro/dxh/service/ExpertService.class.php on line 2

解决方法

  1. 在require时加上dirname(__FILE__),像这样: require_once(dirname(__FILE__)."/../lib/DBUtil.class.php");
  2. 如下理解 require_once实例:
<?php
 //如果b.php被其他目录里的a.php文件require 或者 include 去引用的话 require_once("./c.php"); 
 //实际上调用的是a.php目录下的c.php require_once(dirname(__FILE__)."/c.php"); 
 //实际上调用的是b.php目录下的c.php require_once("c.php"); 
 //实际上调用的是b.php目录下的c.php
?>

案例三:

运行php网站,出错,内容如下:

Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

Fatal error: Unknown: Failed opening required 'E:/php/www/mrsoft/注册登录模块/index.php' (include_path='.;C:/php5/pear') in Unknown on line 0

解决方法:

apache不能解析上图中“注册登录模块”的中文URL,把它换成英文路径即可。

总结:

关于failed to open stream: No such file or directory出现的问题,大体就分为这3大类型。如果你也遇到了这样的报错,你可以仔细比对属于哪个类型的错误。根据上面的提示和解决办法处理,相信很快就能解决问题。


CRMEB-慕白寒窗雪 最后编辑于2023-05-17 18:32:17

快捷回复
回复({{post_count}}) {{!is_user ? '我的回复' :'全部回复'}}
回复从新到旧

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest==1? '取消推荐': '推荐'}}
{{item.floor}}#
{{item.user_info.title}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
{{item.like_count}}
{{item.showReply ? '取消回复' : '回复'}}
删除
回复
回复

{{itemc.user_info.nickname}}

{{itemc.user_name}}

作者 管理员 企业

回复 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}   {{itemc.ip_address}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
查看更多
回复
回复
2849
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

CRMEB-慕白寒窗雪 作者
社区运营专员---高冷のBoy | 呆萌のGirl

回答

2175

发布

1774

经验

44951

快速安全登录

使用微信扫码登录
{{item.label}} {{item.label}} {{item.label}} 板块推荐 常见问题 产品动态 精选推荐 首页头条 首页动态 首页推荐
加精
取 消 确 定
回复
回复
问题:
问题自动获取的帖子内容,不准确时需要手动修改. [获取答案]
答案:
提交
bug 需求 取 消 确 定

微信登录/注册

切换手机号登录

{{ bind_phone ? '绑定手机' : '手机登录'}}

{{codeText}}
切换微信登录/注册
暂不绑定
CRMEB客服

CRMEB咨询热线 咨询热线

400-8888-794

微信扫码咨询

CRMEB开源商城下载 开源下载 CRMEB官方论坛 帮助文档
返回顶部 返回顶部
CRMEB客服