2

Trying to get set up and running on a new hosting company after the old one announced they are discontinuing their service at the end of the year, I am having difficulty getting the sites to run. I narrowed it down to Apache's DocumentRoot for each domain showing the Apache default path rather than showing the path to the individual site's file location. In other words, when I run echo $_SERVER ['DOCUMENT_ROOT']; in a test script, it shows the path as /etc/apache2/htdocs when it should show /home/username/public_html/domain.com. They seem unable to fix it so can DocumentRoot be changed through cPanel for each domain?

  • 2
    From the StackOverflow question Setting PHP Document Root on webserver this happens when your host is using mod_vhost_alias under Apache 2.2. – Stephen Ostermiller Sep 6 '20 at 22:11
  • Thank you and the question is how to fix it. Does that mean that they need to disable mod_vhost_alias and is that something that can be done in cPanel? – DonP Sep 7 '20 at 1:05
  • 1
    The StackOverflow question has two ways your host could fix it. There is a PHP script they could add to correctly set the document root everywhere. They could also upgrade to Apache 2.4 where the problem is fixed. As for fixing it yourself, could you edit all the PHP files and replace the $_SERVER ['DOCUMENT_ROOT'] with something else? – Stephen Ostermiller Sep 7 '20 at 9:07
  • Thank you. None of those things are options, unfortunately, and I just got word that the hosting company (Hostgator) will not fix it so I am cancelling the service and going elsewhere. – DonP Sep 7 '20 at 17:42
  • 1
    Have you been able to confirm what Apache version you have at Hostgator? Apache 2.2 was EOL over 2 years ago and Hostgator state they use Apache 2.4 on all shared servers? What service are you using? A "shared account" with multi-domain support? – MrWhite Sep 7 '20 at 19:29

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.