首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP :有效的open_basedir限制

PHP :有效的open_basedir限制
EN

Stack Overflow用户
提问于 2013-01-22 18:09:06
回答 2查看 27.3K关注 0票数 1

我使用这个Yubico身份验证PHP类:https://github.com/Yubico/php-yubico。我用以下代码创建了php文件test.php:

代码语言:javascript
复制
<?php
 require_once 'Auth/Yubico.php';
 $otp = "ccbbddeertkrctjkkcglfndnlihhnvekchkcctif";

 # Generate a new id+key from https://api.yubico.com/get-api-key/
 $yubi = new Auth_Yubico('42', 'FOOBAR=');
 $auth = $yubi->verify($otp);
 if (PEAR::isError($auth)) {
    print "<p>Authentication failed: " . $auth->getMessage();
    print "<p>Debug output from server: " . $yubi->getLastResponse();
 } else {
    print "<p>You are authenticated!";
 }
?>

完成这个github库中的所有指令。当我打开这个脚本时,我得到:

警告: require_once():有效的open_basedir限制。文件(/usr/share/php/Auth/yubico.php)不在允许的路径范围内:(/var/www/hmci/data:.)在第2行的/var/www/hmci/data/www/hmci.ru/php-yubico/test.php中,警告: require_once(/usr/share/php/Auth/Yubico.php):未能打开流:在第2行的/var/www/hmci/data/www/hmci.ru/php-yubico/test.php中不允许的操作: require_once():failed需要'Auth/Yubico.php‘(include_path=’.:/usr/share/php):/usr/share/pear')在第2行的/var/www/hmci/data/www/hmci.ru/php-yubico/test.php中

如何解决这个问题?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-01-22 18:19:20

open_basedir是一个PHP选项,限制PHP对特定目录的访问。

您的包含路径中有目录/usr/share/php,而没有访问它的权限。通常,PHP逐个地尝试include_path中的所有路径。这意味着PHP无法在当前目录中找到文件Auth/Yubico.php,因此PHP下一步将在/usr/share/php中搜索。

确保您想要包含的文件实际上在那里。您还可以从包含路径中删除/usr/share/php (通过编辑php.ini文件,如果您可以访问它,则使用ini_set()方法)。

票数 2
EN

Stack Overflow用户

发布于 2015-08-26 17:12:08

使用要包含的文件的显式路径导致PHP跳过目录扫描,导致错误:

代码语言:javascript
复制
require_once dirname(__FILE__) . '/Auth/Yubico.php';
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14465212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档