It took me a while to figure out why posix_getgid, posix_getegid, posix_getuid and posix_geteuid weren't working on my CentOS 7 installation of PHP. In fact none of the POSIX commands were available. PHPInfo revealed nothing, it didn't even mention POSIX. On checking the PHP web site it said that all the posix_* commands were built in and needed no configuration to switch them on!
I did a bit of hunting around and I found that RHEL and CentOS distributions of Linux compiled their version of PHP without this module, sighting that it was a security hole to allowed these commands to be run.
If you really want it for development servers, then you can easily install it via the yum process:
yum install php-process
but you must restart httpd after installing it:
systemctl stop httpd
systemctl start httpd
posix_geteuid
andposix_getpwuid(posix_geteuid())
to determine the account under which PHP was running on several systems. They worked with one hosting account, but not on two CentOS 7 systems, though when I checked on the existence of the functions withif (function_exists('posix_geteuid')); { print "Function posix_geteuid exists"; }
andif (function_exists('posix_getpwuid')); { print "Function posix_getpwuid exists"; }
the functions seemed to exist on the system. Even though I was able to use other methods to determine the account under which PHP was running (http://support.moonpoint.com/languages/php/running_under_acct.php), I spent a lot of time trying to understand why the POSIX functions weren’t working before finding this article.