Plesk 上的 PHP - 无法查看绝对目录
我在 Plesk 管理的 Web 服务器上安装了 PHP。我遇到了一些 PHP include_path 问题,我已将其范围缩小到绝对路径,但显然不起作用。
因此,如果我尝试执行目录列表,则以下工作有效:
echo "<h3>Directory listing of .</h3>";
foreach (new DirectoryIterator('.') as $fileInfo) {
if($fileInfo->isDot()) continue;
echo $fileInfo->getFilename() . "<br>\n";
};
但这没有输出。 (那里有文件)。
echo "<h3>Directory listing of /var/www</h3>";
foreach (new DirectoryIterator('/var/www') as $fileInfo) {
if($fileInfo->isDot()) continue;
echo $fileInfo->getFilename() . "<br>\n";
};
输出:
Directory listing of .
.htaccess
index.php
try.php
Directory listing of /var/www
有什么想法吗?
I have PHP installed on a web server administered by Plesk. I am having some PHP include_path problems which I have narrowed down to absolute paths apparently not working.
So, if I try to do a directory listing, the following works:
echo "<h3>Directory listing of .</h3>";
foreach (new DirectoryIterator('.') as $fileInfo) {
if($fileInfo->isDot()) continue;
echo $fileInfo->getFilename() . "<br>\n";
};
But this gives no output. (There are files there).
echo "<h3>Directory listing of /var/www</h3>";
foreach (new DirectoryIterator('/var/www') as $fileInfo) {
if($fileInfo->isDot()) continue;
echo $fileInfo->getFilename() . "<br>\n";
};
Output:
Directory listing of .
.htaccess
index.php
try.php
Directory listing of /var/www
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果这是多站点服务器设置,这可能是正常行为。 Plesk(或系统的其他部分)会将您的 PHP 实例限制在当前站点,并且不允许查看常规
var/www
目录。你的 PHP 是以什么用户身份运行的?
该用户是否有权访问/var/www?
If this is a multi-site server setup, this may be normal behaviour. Plesk (or some other part of your system) would confine your PHP instance to your current site, and not allow a peek into the general
var/www
directory.What user is your PHP running as?
Does that user have the right to access /var/www?
Plesk 将在 httpd.conf include 中添加如下变量:
这样您就无法列出锁定 httpdocs 和 /tmp 中的任何父文件夹。您可以使用 root ssh 帐户在配置文件中手动添加。
从您的站点编辑 httpd 配置文件:/var/www/vhosts/_your_domain_/config/._httpd.include(Plesk 10 是动态名称,随时间戳)。
您可以在其中搜索 php_admin_value open_basedir 并使用 : 分隔符添加您希望有权访问的文件夹。例如:
但是如果您想为所有网站添加文件夹访问权限,例如 /usr/share/pear 文件夹,您将需要编辑 plesk 面板文件。
编辑 /usr/local/psa/admin/conf/templates/default/service/php.php,从: 更改
为:
请记住,这将授予对该文件夹的所有网站的访问权限,可能会破坏服务器安全。请自行承担风险。请记住,如果 plesk 更新将会删除您的更改。
Plesk will add a variable like this in the httpd.conf include:
so you can't list any parent folder from your lock httpdocs and /tmp. You can add manualy in your config file using a root ssh account.
Edit the httpd config file from your site in: /var/www/vhosts/_your_domain_/config/._httpd.include (the Plesk 10 is a dynamic name that changes with a timestamp).
There you can search for php_admin_value open_basedir and add the folder that you want have access using : separator. Like:
But if you want to add a folder access for all your websites, like /usr/share/pear folder, you will need to edit the plesk panel files.
Edit /usr/local/psa/admin/conf/templates/default/service/php.php, change from:
To:
Remamber that will give access to all websites to the folder, can break the server security. Do at your own risk. And remamber that if plesk get updated will erase your changes.