【问题标题】:PHP Fatal error: require(): Failed opening required 'template/header.phtml' (include_path='.:/usr/share/php')PHP 致命错误:require():无法打开所需的 'template/header.phtml' (include_path='.:/usr/share/php')
【发布时间】:2021-03-30 05:09:17
【问题描述】:

我创建了一个网站并将其上传到虚拟主机上,但是当我尝试访问它时,我得到“此页面无法正常工作(HTTP 错误 500)”,我从错误日志文件中得到了这个,我了解这与文件路径有关,但我不知道如何解决。有人知道怎么解决吗?

[Sun Dec 20 00:18:28.000823 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP Warning:  require(/home/ae504/public_html/AuctionSystem/View/Template/header.phtml): failed to open stream: No such file or directory in /home/aee504/public_html/AuctionSystem/View/index.phtml on line 1
[Sun Dec 20 00:18:28.000849 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP Stack trace:
[Sun Dec 20 00:18:28.000853 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP   1. {main}() /home/aee504/public_html/AuctionSystem/index.php:0
[Sun Dec 20 00:18:28.000856 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP   2. require_once() /home/aee504/public_html/AuctionSystem/index.php:5
[Sun Dec 20 00:18:28.000859 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP Fatal error:  require(): Failed opening required '/home/ae504/public_html/AuctionSystem/View/Template/header.phtml' (include_path='.:/usr/share/php') in /home/aee504/public_html/AuctionSystem/View/index.phtml on line 1
[Sun Dec 20 00:18:28.000862 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP Stack trace:
[Sun Dec 20 00:18:28.000865 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP   1. {main}() /home/aee504/public_html/AuctionSystem/index.php:0
[Sun Dec 20 00:18:28.000868 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP   2. require_once() /home/aee504/public_html/AuctionSystem/index.php:5

【问题讨论】:

  • 你能显示导致错误的代码吗?
  • @El_Vanja
  • 似乎您正在使用完整路径来访问您的文件。你应该使用相对路径。此文件位于服务器中的不同位置。
  • 相对文件名怎么写,会是这样的/././././View/Template/header.phtml?
  • 相对意味着与当前文件夹相比。因此,如果您的 index.php 已经在 View 中,则相对路径将为 Template/header.phtml,因为这是您必须添加到当前位置才能访问文件的内容。

标签: php filepath


【解决方案1】:

/home/ae504/public_html/AuctionSystem/View/Template/header.phtml

文件不存在或不可读。简单的 *nix 错误

您的模板引擎没有生成它,或者它正在生成但不可读。鉴于您的错误报告,无法判断。建议你去看看你正在使用的任何框架。

【讨论】:

猜你喜欢
  • 2014-03-05
  • 2019-06-07
  • 2016-02-07
  • 2018-02-22
  • 2016-10-05
  • 1970-01-01
  • 2018-04-27
  • 2023-04-02
  • 2020-10-02
相关资源
最近更新 更多