How to check what user php is running as?

I need to detect if php is running as nobody. How do I do this?

Are there any other names for “nobody”? “apache”? Any others?


If available you can probe the current user account with posix_geteuid and then get the user name with posix_getpwuid.

$username = posix_getpwuid(posix_geteuid())['name'];

If you are running in safe mode however (which is often the case when exec is disabled), then it’s unlikely that your PHP process is running under anything but the default www-data or apache account.

Leave a Reply

Your email address will not be published. Required fields are marked *