编辑:这不是 open_basedir restriction in effect. File(/) is not within the allowed path(s): 的副本.这个问题与 PHP 设置无关,因为我有几个网站在相同的 map 结构和相同的 PHP 设置下工作。请在将其标记为重复之前阅读整个问题,正如我在该问题的最后 4 段中所解释的那样。此外,另一个问题的答案是针对 Apache 的,而我使用的是 Nginx,它不使用 CPanel 或 httpd.conf。
我已手动将我的 Wordpress 网站移至新服务器。对于最后一个,我收到此错误:
Warning: is_dir(): open_basedir restriction in effect. File(/) is not
within the allowed path(s):
(/var/hpwsites/u_bcsautoborg:/usr/share/pear/) in
/var/hpwsites/u_bcsautoborg/website/html/webroot/wp-includes/functions.php on
line 1585
我以前在网站上遇到过类似的错误,但那是由于 upload
文件夹没有从 Wordpress 设置中正确链接到。因此,错误显示不同的行号。
第 1585 行是:
while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
并且是更大块的一部分:
/*
* Safe mode fails with a trailing slash under certain PHP versions.
* Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
*/
$target = rtrim($target, '/');
if ( empty($target) )
$target = '/';
if ( file_exists( $target ) )
return @is_dir( $target );
// We need to find the permissions of the parent folder that exists
and inherit that.
$target_parent = dirname( $target );
while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
$target_parent = dirname( $target_parent );
}
这是来自 Wordpress 函数文件。从代码来看,我假设问题出在 $target_parent
上,但我不知道它指的是什么,因为我不太擅长 PHP。
现在我知道 open_basedir restriction
错误通常意味着 PHP.ini 文件的安全设置不正确,不允许 PHP 函数访问所需的文件夹。但是,我敢肯定这里不是这种情况。
这是一个正常运行的网站,与我所有其他网站的结构相同。所有都托管在 Apache 服务器上,我正在迁移到 Nginx 服务器,并且都有自己的目录,有自己的 MySQL 数据库,所有目录都包含相同的文件和文件夹(除了网站特定的文件夹当然)。所有其他网站都在与此相同的设置中完美运行,因此我无法想象这是一个 php.ini 问题。
在之前的案例中,问题出在“上传”文件夹,我仍然能够进入 wp-admin 并通过 Wordpress 设置更改上传文件夹的位置。但是,我现在无法进入任何页面,因为我只收到上述错误,该错误重复到无穷大。
我已经通过 PHPmyAdmin 禁用了所有插件,但无济于事。显然,我已经在 SO、wordpress 论坛、Google 和 DuckDuckGo 上寻找解决方案。我发现了许多类似的问题,但我找到的解决方案都不适合我。
有没有人知道原因可能在哪里?
最佳答案
我遇到了同样的问题,是通过 Google 搜索发现的。 @hicham 上面的评论让我走上了正确的轨道,这是我能够修复它的方法,以防其他人正在寻找。我通过 phpMyAdmin 编辑数据库如下:
- 点击 wp_options 表
- 点击“搜索”,在“选项名称”字段中输入“上传路径”
- 这应该返回一行,其中您的旧主机路径作为“option_value”。双击要编辑的值,并将其更改为新主机上“上传”文件夹的路径(您应该能够通过 FTP 或主机的控制面板找到它)。
关于php - 警告 : is_dir(): open_basedir restriction in effect. 文件 (/) 不在允许的路径内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38019654/