使用 require 引用文件时,报错如下:

require 'https://dev.ryan.com/test.php';

[Sat Mar 19 23:10:50 2011] [warn] mod_fcgid: stderr: 
PHP Fatal error: require_once() [function.require]: Failed opening required '/common/configs/config_templates.inc.php'
(include_path='.:/usr/share/pear:/usr/share/php') in /home/viapics1/public_html/common/configs/config.inc.php on line 158

原因是没理解虚拟服务器路径和文件系统路径。

require 使用文件系统路径,如

/home/viapics1/public_html/common/configs/config_templates.inc.php

解决方法:

先使用  $_SERVER['DOCUMENT_ROOT']  获取 web 服务器根目录

修改后代码如下:

require_once $_SERVER['DOCUMENT_ROOT'].'/common/configs/config_templates.inc.php';

参考:

https://stackoverflow.com/questions/5364233/php-fatal-error-failed-opening-required-file

踩坑 PHP Fatal Error Failed opening required File的更多相关文章

  1. kinaba 安装踩坑: FATAL Error: [elasticsearch.url]: definition for this key is missing

    操作系统:Linux kibana 版本: 7.4.0 1. 在/etc/yum.repos.d/ 下新建 kibana.repo  配置 yum 源地址 内容如下: [root@localhost ...

  2. kinaba 安装踩坑: FATAL Error: [elasticsearch.url]: definition for this key is missing 转

     安装  https://www.jianshu.com/p/875457cb8da6   操作系统:Linux kibana 版本: 7.4.0 1. 在/etc/yum.repos.d/ 下新建 ...

  3. Symfony没有安装依赖_PHP Fatal error: require(): Failed opening required

    $ php bin/console server:run PHP Warning: require(D:\home\workspace\pd\app/../vendor/autoload.php): ...

  4. PHP message: PHP Fatal error: require(): Failed opening required

    PHP message: PHP Warning: require(/data/wwwroot/blog.sgfoot.com/bootstrap/autoload.php): failed to o ...

  5. TP5报错Fatal error: require(): Failed opening required '/home/www/xx/public/../thinkphp/start.php

    https://jingyan.baidu.com/article/afd8f4deb784fe34e386e97b.html https://www.cnblogs.com/300js/p/9224 ...

  6. PHP错误解决:Fatal error: Unknown: Failed opening required ...

    最近学习PHP,使用XAMPP在Ubuntu下配置完Apache等之后,尝试了一下,但出现如下错误: Warning: Unknown: failed to open stream: 鏉冮檺涓嶅 i ...

  7. Android Studio 首坑 Gradle sync failed: Cause: error in opening zip file 的错误

    前言 今天安装Android studio 2.3.1时发生了一个错误,安装完成后创建第一个Hello World项目是报错.经过这个百度后,结果没有一个靠谱的.将拆解经过记录一下. 环境: 操作系统 ...

  8. Failed opening required

    报错 点击页面右下角的图标,再点击错误可以显示报错.或者在项目中runtime--log也可以查看error [64]think\\__require_file(): Failed opening r ...

  9. 解决:[DCC Fatal Error] **.dpk : E2202 Required package '***' not found

    //[DCC Fatal Error] **.dpk : E2202 Required package '***' not found 意思是:[DCC致命错误] *:e2202需包***没有发现 D ...

随机推荐

  1. 富文本编辑器Ueditor的使用

    1.下载:http://ueditor.baidu.com/website/download.html. 2.解压,并放到项目webapp下. 3.jsp页面的配置. 4.配置根路径. 5.页面展示: ...

  2. [转载]正则表达式参考文档 - Regular Expression Syntax Reference.

    正则表达式参考文档 - Regular Expression Syntax Reference. [原创文章,转载请保留或注明出处:http://www.regexlab.com/zh/regref. ...

  3. js 对象字面量

    对象字面量的输出方式以及定义好处 1.对象字面量的输出方式有两种:传统的'.' 例如:box.name 以及数组方式,只不过用数组方式输出时,方括号里面要用引号括起来 例如:box['name'] v ...

  4. ModelName标记的使用

    再项目中出现这样的错误: A model description could not be created. Duplicate model name 'ExamInfoParams' was fou ...

  5. hdu-1757 A Simple Math Problem---矩阵快速幂模板题

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1757 题目大意: 求递推式第k项模m If x < 10 f(x) = x.If x > ...

  6. 在Spark集群中,集群的节点个数、RDD分区个数、​cpu内核个数三者与并行度的关系

    梳理一下Spark中关于并发度涉及的几个概念File,Block,Split,Task,Partition,RDD以及节点数.Executor数.core数目的关系. 输入可能以多个文件的形式存储在H ...

  7. expect脚本中,变量的写法

    一.expect脚本中,变量的不同写法 shell脚本中定义时间变量的写法:time=`date "+%Y%m%d"` ==>>直接照搬到expect中,设置的变量是不 ...

  8. python request下载文件时,显示进度以及网速

    import requests import time def downloadFile(name, url): headers = {'Proxy-Connection':'keep-alive'} ...

  9. 使用pip 提示UnicodeDecodeError: 'ascii' codec can't decode解决方法

    python目录 Python27\Lib\site-packages 建一个文件sitecustomize.py 内容写: import sys sys.setdefaultencoding('gb ...

  10. java基础编程——二维数组中的查找

    题目描述 在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数 ...