Categories

Featured templates

Open_basedir限制生效. 文件(X)不在允许的路径(s)内:Y

Alex Ross October 22, 2012
Rating: 3.3/5. From 15 votes.
Please wait...

PHP open_basedir保护调整是一种安全模式安全措施,防止用户打开位于其家之外的文件或脚本 directory 使用PHP,除非文件夹特别排除. PHP open_basedir设置(如果启用), 确保所有的文件操作被限制在一定的文件下 directory, 从而防止特定用户的PHP脚本访问未授权用户帐户中的文件. When a script 尝试使用fopen()或gzopen()打开文件时,将检查文件的位置. 当文件超出指定的或允许的范围时 directory-tree, PHP将拒绝打开它,并可能出现以下错误:

Warning: file_exists() [function.: open_basedir限制生效. File(/home/user_name/public_html/ wp-content /上传/ 2006/12 /图片.(/home/user_name:/usr/lib/php:/usr/local/lib/php:/tmp) /home/user_name/public_html/wp-admin/inline-uploading.php on line 226

请查看PHP官方手册以了解更多信息 open_basedir.

我们强烈建议您联系您的 hosting 供应商,并要求他们为您解决问题.

有两种方法可以解决这个问题:

  1. open_basedir限制问题的解决方案或解决方法是完全禁用PHP的open_basedir保护, 或者排除对某些特权用户帐户的保护, 或者允许访问附加的 directory for PHP scripts.

    • If you’re using cPanel WebHost Manager (WHM), 您可以很容易地禁用PHP的open_basedir保护或将某些用户排除在保护之外 WHM. 只需转到“安全”部分下的“调整安全”, 然后选择" Configure "链接为" Php open_basedir Tweak ". Inside it, 您可以启用或禁用php open_basedir保护, 或者从保护中排除和包含主机.

    • If you’re using Plesk hosting control panel, you may need to manually edit Apache configuration file of vhost.conf and vhost_ssl.在“php_admin_value open_basedir”文件中添加或编辑如下行:

      php_admin_value open_basedir none Php_admin_value open_basedir /full/path/to/dir:/full/path/to/directory/httpdocs:/tmp

      open_basedir后面的路径(上面只是示例,将被实际路径替换)是vhost中专门允许PHP脚本使用的目录 domain account to access, 因此,您可以添加更多的目录,文件存储和需要PHP打开, each seperated by color “:”. 但是要小心,因为它可能会使您的系统暴露在安全欺诈中.

      完成后,运行下面的命令使更改生效,然后重新启动 Apache HTTPD web服务器(apache2ctl restart或HTTPD restart)

  2. If you have to manually edit the Apache 要禁用PHP的open_basedir保护,只需打开httpd . conf配置文件.. Conf文件,搜索以以下字符开头的行:

    php_admin_value open_basedir …..

    将虚拟主机下的整行替换为 domain 要禁用保护的用户帐户,用以下行来禁用保护:

    php_admin_value open_basedir none
  3. 您还可以选择允许PHP脚本访问额外的 directory 而不是禁用保护. Additional directory 可以添加到行中,用颜色“:”分隔. For example, to add /new_directory to the allow list:

    “/home/user_account/:/usr/lib/php:/usr/local/lib/php:/tmp” Php_admin_value open_basedir " /home/user_account/:/usr/lib/php:/usr/local/lib/php:/tmp:/new_directory

    Restart the Apache after finished editing. Note that the directory 上面的允许列表限制实际上是一个前缀,而不是 directory name. 这意味着" open_basedir = /dir/incl "也允许访问" /dir/include "和" /dir/incls ",如果它们存在的话. 当您希望将访问限制为仅对指定的 directory, end with a slash. 例如:" open_basedir = /dir/incl/ ".

This entry was posted in Hosting FAQ, Website & server errors and tagged effect, open_basedir, restriction. Bookmark the permalink.

Submit a ticket

如果您仍然无法找到关于您的问题的足够的教程,请使用以下链接向我们的技术支持团队提交请求. 我们将在接下来的24小时内为您提供我们的帮助和协助: Submit a ticket