【问题标题】:open_basedir restriction in effect error in php codephp代码中的open_basedir限制有效错误
【发布时间】:2012-11-17 07:48:24
【问题描述】:

我是 php 语言的初学者。在我的网络项目中,我创建了一个 filepath.config.ini 文件,该文件将所有文件路径存储在网站目录中。例如。 CLASS1 = bin/myclass1.php CLASS2 = bin/myclass2.php

我通过以下方式访问这些路径:

require $_SERVER['DOCUMENT_ROOT'].'/'.GetfilePath('CLASS1');

在 localhost 服务器中,它运行良好并给了我这样的路径

D:/myproject/bin/myclass1.php

当我在测试服务器上上传这些文件时,我得到了这个 open_basedir 限制错误。

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/usr/local/apache/htdocs/projectfolder/bin/myclass1.php) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) 

我知道我们可以禁用此限制...但我不知道该怎么做:P。 但是使用这个服务器 DOCUMENT_ROOT 好不好??? 还是他们使用文件路径的任何替代方式?你们人们为访问这些文件路径所做的事情。 如果我禁用 open_basedir 限制会发生什么?这样做安全吗? 请帮我做什么?

【问题讨论】:

  • 错误指向本地路径 (?):文件(/usr/local/apache/htdocs/projectfolder/bin/myclass1.php) 不在允许的路径内

标签: php filepath document-root open-basedir


【解决方案1】:

编辑您的 php.ini 文件 (PHP: Configuration Changes) 并禁用 open_basedir 或添加 /usr/local/apache/htdocs。

【讨论】:

    猜你喜欢
    • 2013-01-06
    • 2011-03-16
    • 1970-01-01
    • 2011-05-09
    • 1970-01-01
    • 2014-09-27
    • 1970-01-01
    • 2012-05-02
    • 1970-01-01
    相关资源
    最近更新 更多