使用 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. POJ 3187 Backward Digit Sums (递推,bruteforce)

    第1行j列的一个1加到最后1行满足杨辉三角,可以先推出组合数来 然后next_permutation直接暴. #include<cstdio> #include<iostream&g ...

  2. Problem A: C语言习题 链表建立,插入,删除,输出

    #include<stdio.h> #include<string.h> #include<stdlib.h> typedef struct student { l ...

  3. NodeJS--exports和module.exports

    继续迁移印象笔记中记录相关笔记,其实工作中遇到的很多问题当时解决了,后期就忘记了,多记录还是很有用的,好记性不如烂笔头嘛,以后要养成好习惯. NodeJS中 require 用来加载代码,而 expo ...

  4. Django项目中"expected str, bytes or os.PathLike object, not list"错误解决:

    对于这个错误,也在于自己对django基础的掌握不是很牢固,忽略了MEDIA_ROOT的类型是string,而不是list. 错误的写法: MEDIA_ROOT = [ os.path.join(BA ...

  5. (79)zabbix key总是not supported的解决方法

    zabbix定义好key之后,总是会出现Not supported,看到这个问题,大家不用着急,问题其实很容易解决,首先鼠标点击当前key的大红叉上,会显示出报错内容. 常见的有: 1. zabbix ...

  6. 在基于vue-cli的项目自定义打包环境

    在工作当中,遇到了下面这个问题: 测试环境与生产环境中的用户权限不一样,因此,就需要根据测试环境打一个包,生产环境又打一个包.可是,如果每次打包都需要更改权限的配置文件的话,会很麻烦,而且,体现不出一 ...

  7. 【Mysql】mysql中bigint、int、mediumint、smallint 和 tinyint的取值范围

    1.bigint 从 -2^63 (-9223372036854775808) 到 2^63-1 (9223372036854775807) 的整型数据(所有数字),无符号的范围是0到 1844674 ...

  8. MYSQL 自定义排序

    在mysql order by排序中,大多数情况下仅使用默认排序规则就够了:字符串按字典顺序,数字按大小等等.可有时候,某个字段是有自身业务含义的,比如 type(1,2,3)可能表示早/中/晚,如果 ...

  9. POJ 2299 Ultra-QuickSort 简单题解

    Ultra-QuickSort Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 68874   Accepted: 25813 ...

  10. java一些问题的解答

    1.java 枚举类型和数据二进制等问题思考 以下代码的输出结果是什么?为什么会有这样的输出结果? int X=100; int Y=200; System.out.println("X+Y ...