【问题标题】:File is not within the allowed path (Symfony)文件不在允许的路径中(Symfony)
【发布时间】:2016-07-09 11:29:23
【问题描述】:

我正在做一个非个人项目时突然遇到这个错误。

ExecutableFinder.php 第 59 行中的 ContextErrorException:
警告: is_dir():open_basedir 限制生效。文件(/usr/lib/php)是 不在允许的路径内: (/var/www/allservice:/usr/lib/php:/usr/lib/php5:/tmp:/usr/bin/php)

这是 open_basedir 设置的phpinfo()

/var/www/allservice:/usr/lib/php:/usr/lib/php5:/tmp:/usr/bin/php

我在托管时收到此错误。在本地环境中一切正常。我尝试通过 Composer 重新安装 Symfony 并清理缓存。没有任何帮助。

由于它停止在主机上工作并在本地工作,据我了解这可能是 PHP 或 Apache 设置问题?

这是完整的错误。

  1. 在 ExecutableFinder.php 第 59 行
  2. 在 ErrorHandler->handleError('2', 'is_dir(): open_basedir 限制生效。文件(/usr/lib/php)是 不在允许的路径内: (/var/www/allservice:/usr/lib/php:/usr/lib/php5:/tmp:/usr/bin/php)', '/var/www/allservice/allservice.in.ua/testPHP/vendor/symfony/symfony/src/Symfony/Component/Process/ExecutableFinder.php', '59', 数组('name' => 'java', 'default' => '/usr/bin/java', 'extraDirs' => 数组(), 'searchPath' => 数组('/var/www/allservice', '/usr/lib/php', '/usr/lib/php5', '/tmp', '/usr/bin/php '), '目录' => 数组('/var/www/allservice'), '路径' => '/usr/lib/php'))
  3. 在 ExecutableFinder.php 中的 is_dir('/usr/lib/php') 第 59 行
  4. 在 ExecutableFinder->find('java', '/usr/bin/java') 在 Configuration.php 第 67 行
  5. 在配置->Symfony\Bundle\AsseticBundle\DependencyInjection\{closure}() 在变量节点.php 第 54 行
  6. 在变量节点->getDefaultValue() 在 ArrayNode.php 第 241 行
  7. 在 ArrayNode->finalizeValue(array('debug' => true, 'use_controller' => array('enabled' => true), 'bundles' => array(), 'filters' => array('cssrewrite' => array()))) 在 BaseNode.php 第 303 行
  8. 在 BaseNode->finalize(array('debug' => true, 'use_controller' => array('enabled' => true), 'bundles' => array(), 'filters' => array('cssrewrite' => array()))) 在 Processor.php 第 37 行
  9. 在处理器->进程(对象(ArrayNode), 数组(数组('debug' => true, 'use_controller' => false, 'bundles' => 数组(), '过滤器' => 数组('cssrewrite' => null)), 数组('use_controller' => true))) 在 Processor.php 第 50 行
  10. 在处理器->processConfiguration(object(Configuration), 数组(数组('debug' => true, 'use_controller' => false, 'bundles' => 数组(), '过滤器' => 数组('cssrewrite' => null)), 数组('use_controller' => true))) 在 AsseticExtension.php 中 第 44 行
  11. 在 AsseticExtension->load(array(array('debug' => true, 'use_controller' => false, 'bundles' => array(), 'filters' => array ('cssrewrite' => null)), array('use_controller' => true)), object (ContainerBuilder)) 在 MergeExtensionConfigurationPass.php 第 50 行
  12. 在 MergeExtensionConfigurationPass->process(object(ContainerBuilder)) 在 MergeExtensionConfigurationPass.php 第 39 行
  13. 在 MergeExtensionConfigurationPass->process(object(ContainerBuilder)) 在编译器.php 第 117 行
  14. 在 Compiler->compile(object(ContainerBuilder)) 在 ContainerBuilder.php 第 614 行
  15. 在 ContainerBuilder->compile() 在 bootstrap.php.cache 中 第 2564 行
  16. 在内核->initializeContainer() 在 bootstrap.php.cache 中 第 2343 行
  17. 在内核->boot() 在 bootstrap.php.cache 中 第 2374 行
  18. 在 Kernel->handle(object(Request)) 中 app_dev.php 第 29 行

【问题讨论】:

    标签: php apache symfony


    【解决方案1】:

    这是您的托管 PHP 配置的结果。

    基本上,他们设置了一个open_basedir 配置指令,以防止他们的客户端弄乱他们专用沙箱之外的文件。

    我从您的堆栈跟踪中看到您正试图在 /usr/bin/java 中找到 java 可执行文件,它不在 open_basedir 指定的路径中,因此出现错误。

    您可以尝试说服托管管理员为您更改指令,如果他们不这样做,您将无法执行此操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多