Finding out what user Apache is running as?

If you need to  find which user or group Apache is running as, perhaps try opening the httpd.conf file. There should be an entry there for “User” and “Group”. Not only can you see which user Apache is supposed to be running as, but you can change it if you feel the need to do so.

Also below are some other methods to achieve the objective.

1. Go through config file httpd.conf and find out user and group name:

# egrep -iw —color=auto ‘^user|^group’ /etc/httpd/conf/httpd.conf

Sample Output :

apache-user2

2. With the lsof command

#  lsof -i | grep http

Sample Output :

apache-user3

Where,

  1. httpd (1st column) – Apache service / server name
  2. 29206 (2nd column) – Apache server PID
  3. apche (3rd column) – Apache server username for PID. This gives you apache username.

3. With ps command

# ps aux | egrep ‘(apache|httpd)’

Sample Output :

apache-user4

 

Spread the love

Leave a Reply

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