1

如果这个问题已经回答或另一个愚蠢的问题,首先抱歉,如果已经回答,请告诉我在哪里可以找到答案。

今天,我使用 scandir 从另一个站点获取列表目录,该站点位于同一台机器,但即使我运行 chmod -R 0777 也无法获取列表。

# all bellow code run from site2.com
$location = "/var/www/vhosts/site1.com/site1.com/httpdocs/webdata/";

# this return FALSE
$files = scandir($location);  # return FALSE
$res = opendir($location);
$files = readdir($res);  # return FALSE
closedir($res);

# i try this after chmod -R 0777 /var/www/vhosts/site1.com/site1.com/httpdocs/webdata/
# from terminal with admin account, but still ... FALSE :-(
print(is_readable($location) ? 'TRUE' : 'FALSE');  # print FALSE

我通过使用 exec 函数解决了这个问题,但似乎不推荐(尤其是在 cpanel 上)。问题是为什么在 chmod 之后我仍然无法让 is_readable 函数返回 true ?从搜索 google 和 php 它自己并没有解释为什么会发生这种情况,我已经找到了获取文件列表的方法,但我仍然想知道它为什么会发生(在运行 chmod -R 0777 之后)。

注意:我是那台机器的管理员,那台机器上的所有网站都属于我,所以我不会尝试破解任何客户端网站并使用 ehcp 托管控制面板。

谢谢你。

我喜欢它,这会导致 'open_basedir' 在 php 设置或 apache 设置上受到限制。

很抱歉。

4

0 回答 0