Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

up vote 1 down vote accepted

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

http://www.redhat.com/mirrors/LDP/LDP/solrhe/Securing-Optimizing-Linux-RH-Edition-v1.3/chap29sec254.html

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

 
discard

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.