scanning /home/ with opendir() scanning /home/ with opendir() apache apache

scanning /home/ with opendir()


You can use is_readable('/home/') to check if you have permission. If not you'd need to make sure the directory has read privileges, probably 0755 (rwxr-xr-x)


For security, PHP defines a 'basedir', below which you are not allowed to access. As Aleks G says, there is also the file permissions to consider.

This question talks about how to get around basedir restrictions: How can I relax PHP's open_basedir restriction?

Tom Haigh's answer copied to here:

You can also do this easily on a per-directory basis using the Apache (assuming this is your web server) configuration file (e.g. httpd.conf)

<Directory /var/www/vhosts/domain.tld/httpdocs>php_admin_value open_basedir "/var/www/vhosts/domain.tld/httpdocs:/var/www/vhosts/domain.tld/zend"</Directory>

you can also completely remove the restriction with

<Directory /var/www/vhosts/domain.tld/httpdocs>php_admin_value open_basedir none</Directory>


I'm not a PHP programmer, but I think your problem is that when PHP tries the opendir, it is running with the same user ID as apache has, which may not have permission to read your /home directory.

You could fix that by altering the permissions on /home, or adding the apache userid to whatever group has group ownership of home.

Possibly it is a problem in your Apache configuration file. Even if the filesystem permissions would permit it, your httpd.conf file may not allow access to /home. That would usually be the case if all of your HTML files are in /var/www.

The httpd.conf might be set up to allow serving files out of your users' home directories. In that case the permission would be granted for directories within /home but not for /home itself.