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 am used to have the DocumentRoot being an absolute path to the website's DocRoot location, usually something like /usr/local/www/apache2/data/virtualhost_name. This is then accessible from PHP via $_SERVER['DOCUMENT_ROOT'] variable.

I've hosted websites on several Shared Hosting Providers and they all had it this way. Now I moved to a new provider that has it set up differently. PHP's $_SERVER['DOCUMENT_ROOT'] always shows /. I have several websites on the server in different folders but they still all show / as DocumentRoot.

How can I achieve the same thing on my own development server?

share|improve this question
Are you sure it's an apache server ? – Iain Aug 15 '11 at 7:23
I don't think it's genuine Apache. AFAIK it may be their custom build. – Michal M Aug 15 '11 at 7:49

I'd guess they've CHROOT'd each site, this is common on many shared hosting providers so as not to reveal the directory structure of the server.

In a console, if you do an

ls -l

do the web-server files show as being owned by a site user? I.E. each website has it's own user account on the server. If it does I'd guess it's a CHROOT, which is easy enough to do. (Some instructions here)

Also check to see where the current file is

echo dirname(__FILE__);

(That will show you the directory of the current file, if the document root is '/' then that script should return something like '/myphpfile.php')

While I haven't checked if a CHROOT would change the DOCUMENT_ROOT in PHP, I'd assume it would.

However, I don't see how having the DOCUMENT_ROOT as / would be an issue, so long as you're loading it dynamically from the $_SERVER global rather than hard-coding the directory it shouldn't be a problem.

share|improve this answer
I don't have access to the console unfortunately. Websites are not automatically created with a corresponding ftp account either. All I do is point a domain to a folder on the server via provider's own administration panel (it's a proprietary one). dirname(__FILE__) returns /. – Michal M Aug 17 '11 at 14:06
Having DOCUMENT_ROOT as / is not an issue at all, I am simply wondering how can I achieve that on my local development machine? Just being curious. – Michal M Aug 17 '11 at 14:07
@Michal If you follow the instructions at… you should be able to set up CHROOT jails on your dev box, I'd guess that's all they've done as it's very common – Smudge Aug 17 '11 at 14:08

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.