views:

191

answers:

1

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?

+1  A: 

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?

Pekka
Thanks. I just checked the php user and ran some tests.uid=48(apache) gid=48(apache) groups=48(apache),2521(psaserv)PHP can do an ls of the document root /var/www/vhosts/<my-site>/httpdocs but not /var/www/vhosts/<my-site>/Zend :(From the command line:drwxr-x--- 12 reportingadmin psaserv 4096 Jan 11 12:54 httpdocsdrwx------ 5 reportingadmin root 100 Dec 16 15:39 privatedrwxr-xr-x 11 reportingadmin psaserv 4096 Nov 23 19:54 Zend(Annoying comment formatting fail!)
Dizzley