I have XAMP installed on my mac and I tried running the command –
ps axo user,group,comm | grep httpd to know what user apache is running as.
I am getting multiple results one for root and others as nobody. So what is apache running as? A root or nobody and why do I get both root and nobody? Is it because httpd started as a root and then became nobody?
The result of ps axo user,group,comm | grep httpd I get is –
root 20 /Applications/XAMPP/xamppfiles/bin/httpd nobody -1 /Applications/XAMPP/xamppfiles/bin/httpd nobody -1 /Applications/XAMPP/xamppfiles/bin/httpd nobody -1 /Applications/XAMPP/xamppfiles/bin/httpd nobody -1 /Applications/XAMPP/xamppfiles/bin/httpd nobody -1 /Applications/XAMPP/xamppfiles/bin/httpd nobody -1 /Applications/XAMPP/xamppfiles/bin/httpd nobody -1 /Applications/XAMPP/xamppfiles/bin/httpd nobody -1 /Applications/XAMPP/xamppfiles/bin/httpd nobody -1 /Applications/XAMPP/xamppfiles/bin/httpd nobody -1 /Applications/XAMPP/xamppfiles/bin/httpd nobody -1 /Applications/XAMPP/xamppfiles/bin/httpd
Secondly, when I execute the following script –
echo shell_exec('whoami'); (from https://stackoverflow.com/questions/2509334/finding-out-what-user-apache-is-running-as)
I just get the result as – nobody
The reason I want to know the user is because the php engine is actually able to execute a php file(mysql_details.php) that’s outside the web server root directory. And this mysql_details.php has following permissions – rwxr--r-- i.e. just read permission for other and group. So if apache user is nobody then how can it execute mysql_details.php.
Thanks,
Prat.
The main Apache process is run as root- the other processes are run as nobody. The only processes that handle requests are those that are run as nobody, so that if anyone tries to access a file that nobody can’t access, they’ll get an error (whereas root would be able to access the file).
If you need to execute the file, you can do a few things: