PHP 5: Mass Virtual Hosting points $_SERVER[‘DOCUMENT_ROOT’] to wrong folder

When I set up mass virtual hosting for my servers, it seems PHP won’t get the right $_SERVER[‘DOCUMENT_ROOT’]

Here’s the solution I found:

1.Edit your php.ini (the file location depends onĀ  how you have PHP setup)

2. Edit this section

; Automatically add files before PHP document.
auto_prepend_file = /home/httpd/prepend.php

3. Create the prepend file:


4. Restart your httpd server. I have done this for both Apache 2 and NGINX. (It probably doesn’t matter as it’s a PHP issue)

Tagged , , , . Bookmark the permalink.

Leave a Reply