2

I have an Apache httpd server running on my CentOS server, but apparently it both runs a httpd-process as root and one as the apache user.

See this screenshot of top:

enter image description here

User and group are set to apache in the configuration file, so I'm kind of lost here.

Do any of you know what starts the "root" process, and why it's running?

Kenny Rasschaert
  • 8,925
  • 3
  • 41
  • 58

2 Answers2

8

The one running as "apache" is the worker process. The one running as "root" is the master process. This is completely normal.

The master process will spawn workers as necessary (with whatever constraints are specified in the configuration file) to handle incoming traffic. It typically will need to be root in order to bind to low ports 80 and 443. After it binds, it will drop privileges to the apache user.

Workers will be reaped from time to time. The long-running process is the one running as root. If you look at httpd.conf, you'll see a block that looks something like:

StartServers       1
MinSpareServers    1
MaxSpareServers    5
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000

So, the master process will spawn one worker in this example on startup. If there's more traffic, it will spawn more workers. Once workers serve 4000 requests, the worker will die, and the master process may spawn new worker processes, depending on traffic.

cjc
  • 24,533
  • 2
  • 49
  • 69
0

I don't know the why's or the how's but it would seem that the root process is the parent process and the apache owned processes are the children.

I ran pstree -Acp | grep httpd and compared it to ps aux | grep httpd

Safado
  • 4,726
  • 7
  • 35
  • 53