I have php program, that executes a test program with a parameter. That returns json data. I tested with print_r what I get and use a foreach loop to get each row.
$jsondata = shell_exec("/bin/test node");
$data = json_decode($jsondata, true);
...
print_r($data);
/* output:
Array
(
[nodes] => Array
(
...
*/
foreach ($data['nodes'] as $node) {
...
The result should be a table in html. The command line prints out that table as expected. If I try to execute that script via web I get an error:
The error in the log file:
2019/04/02 18:41:33 [error] 1482#1482: *14607 FastCGI sent in stderr: "PHP message: PHP Warning: Invalid argument supplied for foreach() in /media/... xxx.com/test.php on line 85" while reading response header from upstream, client: 192.168.178.1, server: xxx.com, request: "GET /Lightning/listnodes.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "xxx.com"
If I pipe the test program to 1.html and display it in a web browser, it works.
www-rootor similar) has permission to execute that file.