编程技术分享平台

网站首页 > 技术教程 正文

将网站从IIS移到nginx上时出现require(): Failed opening required

xnh888 2024-10-12 13:57:51 技术教程 25 ℃ 0 评论

近日发现将PHP网站从IIS平台移到nginx上时,出现了 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 问题,这个问题的主要原因在于 requre 引用文件时发生了错误。

解决方法就是requre时使用文件系统路径,而不是相对路径。即使用$_SERVER['DOCUMENT_ROOT'] 获取 web 服务器根目录。

<?PHP

require '/template/default/goods/goodsdetail.php';

?>

修改后为

<?PHP

require $_SERVER['DOCUMENT_ROOT'].'/template/default/goods/goodsdetail.php';

?>

就完美可解决这个错误。

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表