How do I tell if apache is running as prefork or worker?

Solution 1:

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.

Solution 2:

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 at the present time.

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 (e.g. /etc/sysconfig/httpd on CentOS / RedHat)
  2. Add or uncomment this line: HTTPD=/usr/sbin/httpd.worker
  3. Restart Apache

Which MPM is actually 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 many, many 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.

Solution 3:

In Ubuntu 14.04

a2query -M

Tells event, prefork, worker

You can change it by adding symbolic links for mpm_<chosen> from mods-available to mods-enabled in /etc/apache2.

Only one is allowed in a time.

Solution 4:

On RedHat and derivates, just launch top or ps aux and look at the httpd process name:

  • httpd means Apache is running as prefork
  • httpd.worker means it is running as worker

Solution 5:

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.