【发布时间】:2012-06-18 20:45:16
【问题描述】:
我使用 PHP Includes 构建了一个非常简单的网站来显示页脚和侧边栏,当我在计算机上并使用 EasyPHP 查看它们时,这些 PHP 包括工作,但是当我上传网站并查看它时,我在页面上显示以下错误:
Warning: include() [function.include]: open_basedir restriction in effect.
File(/usr/local/apache/htdocs/includes/sidebar.php) is not within the allowed path(s):
(/home/:/usr/lib/php:/tmp) in /home/a5562725/public_html/index.php on line 26
Here's the site, 在 000webhost 上免费托管。
这是 index.php 中包含的示例,用于在我的“包含”文件夹中显示侧边栏:
<?php include $_SERVER['DOCUMENT_ROOT'] . "/includes/sidebar.php"; ?>
我正在使用 DOCUMENT_ROOT 而不是普通的包含,因为某些页面嵌入在更深的目录中,并且包含将成为死链接。
【问题讨论】:
-
可能是权限问题。确保 apache 用户能够打开 sidebar.php。如果不确定,请将 /includes/sidebar.php 设置为具有 755 权限。