문제

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;
             }
         }
    ?>
도움이 되었습니까?

해결책 3

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.

다른 팁

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.

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top