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

来源: failed to open stream: No such file or directory问题解决大全-CSDN博客

这篇文章主要为大家详细介绍了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

解决方法:

在require时加上dirname(__FILE__),像这样: require_once(dirname(__FILE__).”/../lib/DBUtil.class.php”);
如下理解 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大类型。如果你也遇到了这样的报错,你可以仔细比对属于哪个类型的错误。根据上面的提示和解决办法处理,相信很快就能解决问题。
————————————————

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/weixin_64051447/article/details/130746697

赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏