Hi,
I want to get the user and group that APACHE is running in through PHP. Like APACHE normally has the user 'apache' and group 'apache' but it can sometimes be 'httpd' for both or it may have been changed by the server admin. How do I find out the user and group the server is running in?
Thanx,
Sam Rudge

If you can work with numeric IDs as well as the textual ID counterparts, then you can check out this function:

http://se2.php.net/manual/en/function.getmyuid.php

There doesn't appear to be a function allowing you to retrieve the textual ID, but the numeric ID usually works in most scenarios - though obviously not for checking and comparison if your comparison ID is textual.

It is possible that there is a way to do this in the command line (shell), but you'd have to rely on exec() or system() or something to pull that off, and I can't say I even know such a command offhand.

Another possibility would be to scrape the textual ID from phpinfo(). If you try executing phpinfo() you should see that it is listed there, so you could write a regular expression to match the line it occurs on and strip out the text.

Oddly enough I did a print_r call on $_SERVER and it was nowhere to be found in those predefined variables. :(

Interesting question though - let me know if you do end up finding another solution than anything I mentioned here because I'd be interested in knowing if there is a better method for this too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.