I am trying to use php to run some system commands and am getting a behaviour that I don't fully understand. If the php script is run from the command line I get the results I expect. But running it through apache yields mixed results.
For example, I have this simple little php script:
<?php $res = shell_exec("ps -ef"); echo $res; ?>
If I run it from the command line I get the full list of processes as I would expect to see if I had run "ps -ef" directly. However if I run the script through apache, I get a smaller set of processes, most of which are apache-owned, although there are also a few root-owned processes and one that is owned by my regular user. Trying to use other commands gets similar behavior; it works when I run it in CLI mode (e.g. "php test.php"), but not when I pull up the php script in apache. It also doesn't seem to matter which user is running it in CLI mode (I've tested it with root and with my personal user account). It seems like some sort of permissions issue, although it's seemingly not an executable issue since in the example of "ps -ef" I get results in both cases.
I am running on CentOS 8, using apache 2.4.37 and php 8.0.8.
What am I missing?
Thanks,
Gavin