Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Finding the Apache user in PHP, see
// Error reporting
ini_set('display_errors', true);
// Return the Apache user
$tmpFilename = tempnam('/tmp', 'TEST');
$handle = fopen($tmpFilename, 'w');
fwrite($handle, 'testdata');
$info = posix_getpwuid(fileowner($tmpFilename));
$apacheUser = $info['name'];
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Apache user</title>
<style> span.fixed { font-family: courier, fixed; } </style>
<h1>Apache user</h1>
<p>The current Apache user is: <span class="fixed"><?php echo $apacheUser; ?></span></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment