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

How do I tell if apache is running (or configured to run) as prefork or worker?

share|improve this question
1  
or more technically 'compiled to run as' –  Simon Nov 24 '09 at 23:54
add comment

4 Answers

up vote 21 down vote accepted

The MPM is configured at compile time. One way to figure it out afterwards is to list compiled in modules. That list will include the chosen MPM. The listing can be accomplished running the apache binary, with the -l flag.

andreas@halleck:~$ apache2 -l
Compiled in modules:
 core.c
 mod_log_config.c
 mod_logio.c
 worker.c
 http_core.c
 mod_so.c
andreas@halleck:~$

Here we find the module worker.c, hence I'm running the worker MPM.

share|improve this answer
    
This answer is wrong. See my answer. –  Chris Johnson Feb 11 at 19:27
add comment

On RHEL/Fedora/etc, run httpd -V. You will get some output which includes the following:

Server version: Apache/2.2.21 (Unix)
     ...
Architecture:   64-bit
Server MPM:     Prefork
     ...

Here 'Server MPM' is 'Prefork', so my server is running the prefork MPM.

share|improve this answer
    
This answer is wrong. See my answer. –  Chris Johnson Feb 11 at 19:27
    
@ChrisJohnson, interesting discovery... My understanding was that the MPM could not be changed by configuration, only by compilation. It seems the OP thought the same, since he commented on his question with "or more technically 'compiled to run as'". I'll look into reproducing your answer and once I've confirmed it I'll revoke mine. –  Series8217 Feb 12 at 21:30
    
I confirmed via the apache documentation at httpd.apache.org/docs/trunk/mpm.html that MPMs can be built as DSO modules and dynamically loaded with the LoadModule directive, on "Unix and similar platforms". So the MPM can indeed be changed at load time under certain circumstances (which might be the most common configuration these days..) –  Series8217 Feb 12 at 21:37
add comment

The answers given by Series8217 and Andol are both incorrect.

The question was, how to tell if Apache is running prefork or worker. The advice given by the other answers only tells what the default MPM is (based on compiled-in modules), not if that default or another choice is being used.

If httpd -V shows prefork, that just means prefork is the compiled-in default MPM. That can be overridden by changing an Apache configuration file setting, as shown in this process:

  1. Edit the configuration file (/etc/sysconfig/httpd on CentOS / RedHat)
  2. Add or uncomment this line: HTTPD=/usr/sbin/httpd.worker
  3. Restart Apache

Which MPM is running can be shown using this process:

  1. Enable Apache mod_info
  2. Query the mod_info url, typically curl localhost/server-info
  3. The "Server Settings" section will show "MPM Name: Worker"
  4. Run httpd -V again -- it will still show prefork, not worker

Bottom line:

  • httpd -V shows the default option, not which option is actually in use

There are answers on several web sites saying, use httpd -V to tell if Apache is running prefork or worker. They are all wrong. Try the above procedure to see for yourself.

share|improve this answer
    
FYI, according to httpd.apache.org/docs/trunk/mpm.html the MPM can be a static module on all platforms, or built as a DSO (on Unix). When it is built as a static module, "The server must be rebuilt in order to change the MPM." Is the apache documentation incorrect about the static module MPM being unchangeable except by rebuilding the server? –  Series8217 Feb 12 at 21:34
    
This sounds very much like something distro specific, with a higher level wrapper around? –  andol Mar 7 at 9:08
add comment

Chris Johnson is correct. Go to httpd.conf => add this line:

<Location /server-info>
SetHandler server-info
</Location>

Restart apache: /etc/init.d/httpd restart. Then access localhost/server-info by your browser and look at MPM Name section.

share|improve this answer
add comment

Your Answer

 
discard

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