WordPress 出现 open_basedir restriction in effect 错误 修复教程


最近在安装Wordpress主题时出现 open_basedir 报错,我们是用Centos 7 + 宝塔控制面板部署 WordPress 网站环境,在安装 WordPress 程序过程中一直正常,直到安装并启用新主题,就会在前端和 WordPress 后台出现如下所示的错误:

Warning: is_readable(): open_basedir restriction in effect. File(C:wwwrootwww.niuqi360.com/wp-content/plugins/C:/wwwroot/域名/wp-content/plugin/senvato-market/languages/envato-market-en_US.mo) is not within the allowed path(s): (c:/wwwroot/www.niuqi360.com/;C:/Windows/Temp/;C:/Temp/;C:/BtSoft/temp/session/) in C:wwwrootwww.niuqi360.comwp-includesl10n.php on line 748

open_basedir 限制实际上是一种安机制,可防止网络服务器上的用户,访问属于另一个用户的文件和文件夹。

接下来,让我们看看如何解决这个问题。

WordPress 警告:open_basedir restriction in effect

通常,我们在访问该 WordPress 网站时会遇到类似如下所示的这些错误:

open_basedir restriction in effect. File(/tmp) is not within the allowed path(s).
Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/home/some/path/here/) is not within the allowed path(s).
Warning: is_writable() [function.is-writable]: open_basedir restriction in effect.
File(/) is not within the allowed path(s).

修复 VPS 服务器上的 open_basedir 限制错误

如果是在 VPS 或专用主机上,并且安装了宝塔面板或者 cPanel ,要禁用 PHP open_basedir 限制,只要转到对应的设置项中将其禁用即可。

这里以宝塔面板为例。登录宝塔面板后,找到对应的网站并点击设置按钮。然后在网站设置窗口中,点击网站目录。只要在网站目录设置中,取消选中“防跨站攻击(open_basedir)”即可。

图片[1]-WordPress 出现 open_basedir restriction in effect 错误 修复教程-LyleSeo

修复共享虚拟主机上的 open_basedir 限制错误

如果您使用的是共享主机,可能无法禁用 open_basedir 限制。因为您自己没有权限更改,如果您向服务商请求禁用它,服务商也不会答应的。

所以要解决这个问题,请联系虚拟主机服务商,获取虚拟主机上的 tmp 目录或文件夹的路径。然后编辑 wp-config.php 文件以在其中添加此代码,

define('WP_TEMP_DIR' ,'../../relative/path/to/tmp' );

在这里,将“../../relative/path/to/tmp”替换为 WordPress 的 tmp 目录的实际路径。

例如,如果目标 WordPress 站点安装在 www.yoursite.com/blog,并且 tmp 文件夹位于 blog 文件夹的上一层,则要添加到 wp-config.php 文件的代码为:

define('WP_TEMP_DIR' ,'../tmp' )
© 版权声明
THE END
喜欢就支持一下吧
点赞16 分享