I'm running PHP on nginx (on a RPi-4B) that is also running Node-RED.
Is there a way to get hold of... $_SERVER['DOCUMENT_ROOT'] and use it within Node-RED ??
e.g. like executing <?php echo $_SERVER['DOCUMENT_ROOT']; ?> in a PHP script.
I can use the http request node to execute a script and return the value.
I was hoping there might be a way to use something simple like the 'exec' node or equivalent.
Hi Nick,
I've followed your instructions to create a file and call it from the 'exec' node.
It seems to run, well it doesn't give any errors - just code:0, but it doesn't return a value.
Any further suggestions??
I think the main problem is that the php process running the command and the process executing scripts when you use a http request are not the same processes. Maybe it's "easier" to read the nginx configuration to determine the document_root.
I'm not an nginx expert either but maybe you could analyse the sites-enabled directory of your nginx server? I believe the root is defined in one of those files there. On my ubuntu test machine it's /etc/nginx/sites-enabled. You can use the command whereis nginx to get the directories you are looking for.
Edit: Or you could still use the http request approach but instead of returning the absolute path, you are writing it into a file on your server (which only you know, the file I mean) and then read the content of that file from Node-RED.