使用 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. extends 继承

    继承的作用:子类可以直接拥有父类成员:其中,私有成员和构造函数不参与继承: java中类继承的特点:只支持单一继承和多重继承,不支持多继承(一个类不能同时继承多个类) 继承中成员变量的特点:子类中可以 ...

  2. Nginx+Keepalived双主轮询负载均衡

    双主模式使用两个VIP,前段有2台服务器,互为主从,两台服务器同时工作,不存在资源浪费情况.同时在前端的DNS服务器对网站做多条A记录,实现了Nginx的负载均衡,当一台服务器故障时候,资源会转移到另 ...

  3. STL容器 成员函数 时间复杂度表

    Sequence containers Associative containers   Headers <vector> <deque> <list> <s ...

  4. php之基础深入---类与对象篇

    1.类的自动加载: spl_autoload_register()函数可以注册任意数量的自动加载器,当使用尚未被定义的类(class)和接口(interface)时自动去加载,这样可以避免includ ...

  5. hdu-2066 一个人的旅行---模板题

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2066 题目大意: 求到目标点集合中的最短距离 解题思路: dijkstra算法求出每个点到该点的最短 ...

  6. Hybrid App开发之css样式使用

    前言: 前面学习了html,今天学习一下css的基本使用,看下html与css之间是如何结合来编写前端网页的. CSS 是什么? CSS 是 Cascading Style Sheets(级联样式表) ...

  7. MyBatis的discriminator鉴别器根据字段值实现Java中的多态

    <select id="getModelById" resultMap="modelTypeMap"> SELECT id as id, model ...

  8. 导航条(Navbar)

    1.添加.navbar-fixed-top类可以让导航条固定的页面的顶部,固定的导航条会遮住页面上其它的内容,除非给body元素设置padding,导航条默认高度为50px ,因此可以给body元素设 ...

  9. Bootstrap历练实例:popover插件中的方法

    方法 下面是一些弹出框(Popover)插件中有用的方法: 方法 描述 实例 Options: .popover(options) 向元素集合附加弹出框句柄. $().popover(options) ...

  10. 深入理解Java GC

    一.概述 GC(Carbage Collection)垃圾收集器,由JVM自动回收已死亡的对象垃圾. 这也是Java与C++等语言的主要区别之一. 二.如何确认对象已死 1. 引用计数算法 引用计数法 ...