1

I am using PHP's realpath() function, and want to know why I get the following output:

bool(false)
string(48) "/var/www/vhosts/website.co.uk/httpdocs"
bool(false)
string(48) "/var/www/vhosts/website.co.uk/httpdocs"

when running this script:

<?php
error_reporting(-1);
header('content-type: text/plain');

var_dump(realpath('/var/www/vhosts/website.co.uk/application'));
var_dump(realpath('/var/www/vhosts/website.co.uk/httpdocs'));
var_dump(realpath(dirname(__FILE__) . '/../application'));
var_dump(realpath(dirname(__FILE__) . '/../httpdocs'));

exit;

with these file permissions:

drwxr-x---  5 username  psaserv 4096 Jul 16 08:22 application
drwxr-x--- 10 username  psaserv 4096 Jul 16 13:34 httpdocs

Note:

  • This is a Plesk system
  • Script runs as apache user
  • apache user is part of the psaserv group
4

1 回答 1

1

Plesk 和 openbase_dir 限制

除非 plesk 在过去几年发生了变化 -它设置了 open_basedir 限制,以便您只能访问该httpdocs文件夹:

默认的 open_basedir 设置使您能够为每个网站写入 2 个位置。应该没有理由写入任何其他文件夹。[...]

  • /tmp
  • /var/www/vhosts/domain.com/httpdocs

因此,如果请求尝试读取/写入任何其他位置 - 它将无法这样做,因此realpath将为httpdocs文件夹外的任何位置返回 false。


如果您想查看引用的论坛帖子中链接的脚本,它已移动并可在此处找到:unplesk

于 2013-07-16T21:04:02.007 回答