Today an interesting problem has arisen. A piece of code that relies on the Server Document Root suddenly stopped working on only my browsers. My machine is where I develop locally using xampp, and all other machines do not present this problem. This error is occurring on the actual live remote webserver.

The server document root of a remote, live website, is being returned as (/usr/local/apache/htdocs/): failed to open stream: No such file or directory" for me as an error when executing $_SERVER['DOCUMENT_ROOT']. On all other machines and even earlier this week, it was returning the public_html/root directory of my web server just fine. Somehow my machine or browsers are overriding remote document root requests to my local apache installation.

Cache clears, browser re-installs, and reboots have been done. I'm genuinely not sure how to begin to approach this issue. Thank you for your time.

My web host replied that the httpd.conf of my remote server states the following:

<VirtualHost xx.xx.xxx.xx:xx>

DocumentRoot /home/v1/public_html

As for my local xampp, the httpd.conf DocumentRoot line is as follows:

DocumentRoot "C:/xampp/htdocs"

The full error line is as follows:

Warning: parse_ini_file(/usr/local/apache/htdocs/../content/config.ini): failed to open stream: No such file or directory (php file) at line 25.

Line 25 is just a parse_ini_file command that directs to a folder on the server. On other machines, it will properly evaluate as "/home/v1/public_html", but not from my development machine.

  • 1
    Have you checked your hosts file? If you are using the same URL mapped locally then it will return the local webserver. – joesk Jun 6 '17 at 18:27
  • I think you are confused. $_SERVER['DOCUMENT_ROOT'] is server side PHP code. You have a local development website. But you are talking about a remote live website and browser caches. – Stephen Ostermiller Jun 6 '17 at 18:31
  • Yes, my local and live URLs are not using the same urls and are not present in my hosts. – AmarB Jun 6 '17 at 18:35
  • To be able to answer this you will need to give us more to work with. You can edit the question to include relevant details: The lines from your configuration files that set the document root on both your local and remote server. A screenshot from your browser with an error. The full line from your webserver err_log (along with which server the error comes from). – Stephen Ostermiller Jun 6 '17 at 18:39
  • This problem is occurring on the actual remote live website, @StephenOstermiller, not my local. Hence why I am very confused. It was working fine and then threw the error permanently after it was live thirty minutes or so. I can request err_logs from my host and provide them when they are available. My main post has been expanded. – AmarB Jun 6 '17 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.