Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

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.

share|improve this answer
    
Thank you very much! That cleared up the situation quite much :) –  Jacob Pedersen Jan 30 '12 at 22:58

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.