Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've a web server with CentOS and DirectAdmin. I found that php is allowed to ignore the virtual host DocumentRoot. For example the following code:

<?php print_r(scandir('/')); ?>

Result on a listing of the root directory of the server.

Could it be related with SuPHP and php script running with user privileges (which is of course allowed to list the root directory)? How to avoid it and set a path for php / directory? I would love to have / pointing to the virtual host DocumentRoot or, even better, the user home folder.

share|improve this question
up vote 1 down vote accepted

You could try looking to chroot the webserver, something like this may work for what you need.

share|improve this answer

PHP scripts aren't chrooted by default, and so accessing / is expected. You need to specifically configure PHP to chroot scripts if you want this behaviour. How you go about doing this depends on the webserver and how you execute PHP.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.