0

I have a code in PHP, which includes some files using absolute files like:

require_once($_SERVER['DOCUMENT_ROOT'] . "/frontend/src" . "/requests/Requests.inc");

Locally it launches successfully. But when I try to launch it in my NGINX docker container it writes that file isn't found.

NGINX root path: /var/www/html/

Index.php is in: /frontend/src

I tried to determine for my paths, NGINX root as zero point, and changed it too

require_once("/frontend/src" . "/requests/Requests.inc");

Still it doesn't work. Since that moment I don't understand, how does absolute path in NGINX + PHP work?

  • If you log into your container and do `ls /frontend/src/requests`, do you see Requests.inc, or do you get an error? – aynber May 08 '23 at 13:23
  • Given Index.php is in: /frontend/src, it must be the DOCUMENT_ROOT already. Either way, why don't you just echo $_SERVER['DOCUMENT_ROOT'] and see what does it contain? – Your Common Sense May 08 '23 at 13:34
  • 1
    Besides, the error message contains all the information you need - the full path to your script and the full path which is trying to be included. All you need is compare the two – Your Common Sense May 08 '23 at 13:50
  • I tried to print in via echo. In the frist option it returned full path starts from /var/... and it was a real file path in docker. But PHP returned me an exception that this file doesn't exist. In the second option it printed that path: /frontend/src/requests - of cause in docker there is no files, but i thought it counts in NGINX environment – Bogdan Madzhuga May 08 '23 at 18:52

0 Answers0