views:

36

answers:

3

I have 2 folders: /var/www/vhosts/mydomain.com/httpdocs/ and /var/www/vhosts/mydomain.com/httpdocs/duh/

Both folders have the EXACT same perms, group, owner, everything.

If I set $path to the first one, no problems, I echo a list of files with 'html' in the filename.

If I set $path to the second one, it dies on the opendir(). However, it works fine from the command line, just not the browser.

Any ideas?

Here's my very simple code:

<?php
        $path = "/var/www/vhosts/mydomain.com/httpdocs/duh/";

        $img_folder = opendir($path) or die("Unable to open $path");

         while (false !== ($file = readdir($img_folder))){
             if (eregi("html", $file)){
                echo $file;
             }
         }
    ?>
A: 

What are the permissions on the duh folder? Remember that the webserver will be running under a different user ID than your shell account. Make sure the dir's mode 0755 so it's readable by all users.

oops, just your comment with the error message. So, yes, permissions error. duh is owned by user id 10012, while your web server's running as root. safe mode will not allow this. 'chown' the directory to be owned by root...

Of course, why is the webserver running as root? That's horribly insecure.

Marc B
Perms are 755 and I even set the folder's owner to the webserver's uid.
k00k
Webserver is running as apache. What led you to think it was running as root?
k00k
A: 

Well now you know the answer: its SAFE_MODE, one of the ugliest PHP features.
There are some workarounds, but the best of them is run from this host as fast as you can!
or find a way to disable it.

Col. Shrapnel
A: 

I figured it out. The server that I'm working on has local config files for each vhost. safe_mode was set to on for the local conf.

Thanks to those that led me down the path.

k00k