PHP Scripts open_basedir Restriction in Effect Error PHP脚本和open_basedir的限制,实际上是错误
PHP open_basedir protection tweak is a Safe Mode security measure that prevents users from opening files or scripts located outside of their home directory with PHP, unless the folder has specifically excluded. PHP中的open_basedir保护调整,是一种安全模式,安全的措施,阻止用户打开文件或脚本位于以外的其主目录用PHP ,除非该文件夹已明确排除在外。 PHP open_basedir setting if enabled, will ensure that all file operations to be limited to files under certain directory, and thus prevent php scripts for a particular user from accessing files in unauthorized user’s account. PHP中的open_basedir设置如果启用,将可确保所有的文件操作是有限的档案在某些目录中,从而防止PHP脚本为某特定用户从存取档案,在未经授权的用户的帐户中。 When a script tries to open a file with, for example, fopen() or gzopen(), the location of the file is checked.当一个脚本试图打开一个文件,例如fopen ( )或者gzopen ( ) ,该文件的位置被选中。 When the file is outside the specified or permissible directory-tree, PHP will refuse to open it and the following errors may occur:当文件以外的指定或许可的目录树, PHP将拒绝打开它和下面的错误,可能会发生:
Warning: file_exists() [function.file-exists]: open_basedir restriction in effect.警告: file_exists ( ) [ function.file -存在] : open_basedir上的限制作用。 File(/home/user_name/public_html/wp-content/uploads/2006/12/picture.jpg) is not within the allowed path(s): (/home/user_name:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/user_name/public_html/wp-admin/inline-uploading.php on line 226文件( / home/user_name/public_html/wp-content/uploads/2006/12/picture.jpg )不属于允许路径( ) : ( /首页/用户名:在/ usr /库/ PHP的:在/ usr / local / lib中/ PHP的: / tmp的)在/ home /用户名/ public_html /可湿性粉剂-政府当局/内置- uploading.php上线226
The above error message appears on a Apache httpd web server error log (error_log) hosting Wordpress blog.上述错误讯息出现在阿帕奇的httpd的Web Server错误日志( error_log )主办的WordPress博客。 However, the problem may happen to all system or websites that use PHP as scripting language.不过,问题可能出现的所有系统或网站使用PHP作为脚本语言。
The solution or workaround to open_basedir restriction problem is that disable the PHP open_basedir protection altogether, or to exclude the protection for certain privileged user accounts, or to allow access to the additional directory for PHP scripts.该解决方案或替代方法,以和open_basedir的限制,问题是禁用的PHP和open_basedir的保护完全,或排除保护某些特权用户帐户,或让获得额外的目录PHP脚本。
If you’re using cPanel WebHost Manager (WHM), you can easily disable PHP open_basedir protection or exclude certain users from the protection with WHM.如果您使用的cPanel网页主机服务经理(的WHM ) ,您可以轻松地禁用的PHP和open_basedir保护或排除某些用户从保护的WHM 。 Simply go to “Tweak Security” under the “Security” section, then select “Configure” link for “Php open_basedir Tweak”.简单地去“调整安全”下“安全”一节,然后选择“配置”链接“的PHP和open_basedir调整” 。 Inside it, you can enable or disable php open_basedir Protection, or exclude and include hosts from the protection.内,您可以启用或禁用的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.conf, and add in or edit the following php_admin_value open_basedir lines to the following:如果您使用的plesk主机控制面板,您可能需要手动编辑Apache配置文件vhost.conf和vhost_ssl.conf ,并在添加或编辑以下php_admin_value open_basedir上线如下:
<Directory /full/path/to/the/directory/httpdocs> <directory /full/path/to/the/directory/httpdocs>
php_admin_value open_basedir none php_admin_value open_basedir上无
</Directory> < /目录>
<Directory /full/path/to/the/directory/httpdocs> <directory /full/path/to/the/directory/httpdocs>
php_admin_value open_basedir /full/path/to/dir:/full/path/to/directory/httpdocs:/tmp php_admin_value open_basedir上/全/路径/ /迪尔: /充分/路径/ /目录/ httpdocs : /川芎嗪
</Directory> < /目录>
Note: For SSL hosts in the vhost_ssl.conf file, the Directory path will end with “httpsdocs” instead of “httpdocs”.注意:对于SSL主机,在vhost_ssl.conf文件,目录路径将结束与“ httpsdocs ” ,而不是“ httpdocs ” 。
The paths (above is example only and to be replaced with real path) that behind open_basedir are the directories that specifically allowed for the PHP scripts in the vhost domain account to access, so you can add in more directories that files are been stored and needed to be opened by PHP, each seperated by color “:”.路径(以上是例子,只需要更换与实际路径)的背后,和open_basedir是目录,明确允许为PHP脚本,在vhost网域帐户来访问,使您可以添加更多的目录,档案被存放和需要以开放,由PHP ,每个分隔的颜色“ : ” 。 But be careful as it might expose your system to security fraud.但要小心,因为它可能暴露您的系统安全的欺诈行为。
Once done, run the command below to make the changes effective, and then restart Apache httpd web server (apache2ctl restart or httpd restart):一旦这样做,运行该命令下面作出的变化,有效,然后重新启动的Apache的httpd Web伺服器( apache2ctl重新启动或重新启动的httpd ) :
$PRODUCT_ROOT_D/admin/sbin/websrvmng -v -a元product_root_d /管理/ sbin / websrvmng - V型1
If you have to manually edit the Apache configuration file to disable PHP open_basedir protection, simply open up the httpd.conf file, and search for the lines that starts with the following characters:如果您有手动编辑Apache配置文件中禁用的PHP和open_basedir的保护,只要打开了httpd.conf文件,并搜索该行开始与以下字符:
php_admin_value open_basedir ….. php_admin_value open_basedir上… ..
Replace the whole line under the virtual host for the domain user account that you want to disable protection with the following line to disable it:取代整个线下,虚拟主机为域用户帐户您想要停用的保护与下列命令行以禁用它:
php_admin_value open_basedir none php_admin_value open_basedir上无
You can also opt to allow your PHP scripts to access additional directory instead without disabling the protection.您也可以选择,让您的PHP脚本,以获得更多目录,而不是无禁用的保障。 Additional directory can be added to the line, separated with color “:”.额外的目录中可以添加到线,分离与颜色“ : ” 。 For example, to add /new_directory to the allow list:例如,要添加/ new_directory ,以允许名单:
php_admin_value open_basedir “/home/user_account/:/usr/lib/php:/usr/local/lib/php:/tmp” php_admin_value open_basedir上“ /首页/ 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” php_admin_value open_basedir上“ /首页/ user_account / :是/ usr / lib中/ PHP的:是/ usr / local / lib目录/ PHP的: / tmp的: / new_directory ”
Restart the Apache after finished editing.重新启动的Apache后,完成编辑。 Note that the directory allowed list restriction above is actually a prefix, not a directory name.请注意,目录获准名单的限制,上述实际上是一个前缀,而非一个目录名。 This means that “open_basedir = /dir/incl” also allows access to “/dir/include” and “/dir/incls” if they exist.这也就是说“ open_basedir = /迪尔/ incl ”也会允许访问“ / dir /包括”和“ / dir / incls ” ,如果它们存在的话。 When you want to restrict access to only the specified directory, end with a slash.当您要将访问限制在仅为指定的目录,在结尾加上一个斜线。 For example: “open_basedir = /dir/incl/”.例如: “ open_basedir = /迪尔/含/ ” 。
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要说明 :这是一个机器翻译网页是“按原样”提供的担保。 Machine translation may be difficult to understand.机器翻译可能很难理解。 Please refer to请参阅 original English article英文原版的文章 whenever possible.只要有可能。
Share and contribute or get technical support and help at分享和贡献,或取得技术的支持和帮助,在 My Digital Life Forums 我的数字生活论坛 . 。
Related Articles相关文章
- PHP Parse Error: syntax error, unexpected $end PHP的解析错误:语法错误,意想不到的元月底
- PHP Allowed Memory Size Exchausted Fatal Error PHP的允许内存大小exchausted致命错误
- PHP 5 Unable to Open HTTP Request Stream with fopen or fsockopen Functions PHP 5中无法打开HTTP请求流与fopen或fsockopen职能
- Install XCache PHP Accelerator in Linux by Compiling from Source安装xcache的PHP加速器,在Linux的编制从源
- WordPress MySQL SQL Query Error in WPDB Class在WordPress MySQL的SQL查询错误在wpdb级
- gmmktime Error in WordPress and MagpieRSS gmmktime误差在WordPress和magpierss
- Email Bounces Back with “unrouteable mail domain” Error电子邮件反弹与“ unrouteable的邮件域”的错误
- Oracle Database Import Error 3113/3114 Oracle数据库的进口错误三千一百一十四分之三千一百十三
- RapidLeech v2.2 Free Download rapidleech 2.2版本免费下载
- How to Customize, Modify or Change WordPress Database Connection Error Page如何自订,修改或改变的WordPress数据库连接错误页
















December 3rd, 2007 16:21 2007年12月3日16时21分
[...] queréis más información sobre este tema, hay un artículo muy interesante sobre este error en My Digital Life. [ … … ] queréis更多资讯,关于埃斯特特马,干草联合国artículo muy interesante关于埃斯特错误恩,我的数位生活。 Etiquetas: Desarrollo, hosting, open_basedir, [...] etiquetas :与发展,主机托管, open_basedir上, [ … … ]
December 21st, 2007 16:58 2007年12月21日16时58分
Great article.伟大的文章。
Thanks for the WHM tip.感谢为的WHM秘诀。
You saved my ass.你救了我驴。