≡ Menu

Which username is Apache running on?

I need to find the username under which Apache is running on. How do I find this out?

You can either achieve this using the command lsof or look in your httpd.conf file.

Using lsof

Type in the following command on your SSH shell session or your local terminal:

lsof -i
lsof -i | grep httpd

This will output something like the following:

[root@server ~]# lsof -i
sshd      1419   root    3u  IPv4  397592680      0t0  TCP *:ssh (LISTEN)
sshd      1419   root    4u  IPv6  397592682      0t0  TCP *:ssh (LISTEN)
sendmail  1449   root    4u  IPv4  397593101      0t0  TCP localhost:smtp (LISTEN)
httpd     3858   root    3u  IPv4  962382262      0t0  TCP *:http (LISTEN)
httpd    17663 apache    3u  IPv4  962382262      0t0  TCP *:http (LISTEN)
httpd    17740 apache    3u  IPv4  962382262      0t0  TCP *:http (LISTEN)
sshd     22419   root    3u  IPv4 1145994292      0t0  TCP server.freednsreport.net:ssh->ABTS-mum-dynamic- (ESTABLISHED)
[root@server ~]#

So as the above command shows, your Apache httpd process is running under the user root. It is also running under the username apache. It also shows that sshd and sendmail are running as root.

Using httpd.conf

First, locate your httpd.conf file:

httpd -V

Then run the following command:

grep -i User /etc/httpd/conf/httpd.conf

This will output something like the following:

# If you wish httpd to run as a different user or group, you must run
# User/Group: The name (or #number) of the user/group to run httpd as.
#  . On SCO (ODT 3) use "User nouser" and "Group nogroup".
#    suggested workaround is to create a user www and use that user.
User apache

So it is instructed to Apache that it should run as the user apache in the httpd.conf file.

Comments on this entry are closed.