• GoDaddy Community
  • Managed WordPress Hosting
  • Managed WordPress Hosting

    Showing results for 
    Show  only  | Search instead for 
    Did you mean: 

    PHP can no longer read scripts outside DOCUMENT_ROOT

    (Suggestions for a more appropriate forum are welcome.)


    On the last day of September, 2019, something fundamental changed in the way my GoDaddy managed WordPress site manages the run-time servicing of page requests. My child theme's functions.php includes scripts outside the document root by doing this:


    $document_root = $_SERVER['DOCUMENT_ROOT'] ;
    include( "{$document_root}/../my-scripts/setup.php" ); // Read setup from /home/my-username/my-scripts

    This worked for years, but is failing now because PHP cannot access the files in $document_root/..


    $document_root is /var/www and is temporarily linked somehow to be /home/my-username/html (both of those paths have the same inode). However, $document_root/.. is /var, which is not /home/my-username, so PHP cannot see my /home/my-username/my-scripts directory. Making the relative path an absolute one to /home/my-username/my-scripts changes nothing - PHP can see /home but cannot see /home/my-username.


    Playing around with the PHP directives like open_basedir, include_path, or doc_root have not helped so far- PHP just cannot see files in my home directory unless they are also inside html/.


    Did something change last month to break this? More importantly, how do I now correctly access files outside $_SERVER['DOCUMENT_ROOT'] from my PHP scripts? Thanks for any tips or suggestions.

    0 REPLIES 0