I'm running Apache on a Linux server. There are a collection of shell scripts that need to get executed by a PHP script. Apache/PHP on the server is only needed for this one purpose. The shell scripts must be executed by user "X". I've set the User and Group properties in httpd.conf to be for user "X" and its group.
When I call the PHP script, I've included an echo of whoami. It shows user "X". I've also included an output to log file in the shell script that PHP executes that echos whoami and env variables. When the shell script runs, it reports that the user is "X", but the env variables output shows the user to be ROOT. How is this possible? This is ultimately a problem as the shell script won't run properly if it doesn't have access to the env variables for user "X".
[edit] Further clarification. The issue exists at the PHP script level too, so to simplify things, I can rephrase the issue that when I have Apache configured in httpd.conf to run as user "X", and if I trigger a PHP script that echos "whoami" and "env", then I see that "whoami" is user "X" but the "env" details are for user "root". the PHP script would look something like this...
<?php
echo "<br>". exec('whoami');
exec('env', $envo);
echo "<br>". print_r($envo);
?>