Website Scripts And Cloud Tutorials

Apache change MPM prefork to worker module


Jan 18, 2016

Last updated on February 8th, 2022 at 02:07 pm

Click to rate this tutorial!
[Total: 1 Average: 5]

Apache change from prefork to worker MPM

Starting from Apache version 2.4 we cannot change the setting inside /etc/sysconfig/httpd. As per Apache, HTTPD variable is now ignored.

MPM is a loadable module, and choice of MPM can be changed by editing the configuration file /etc/httpd/conf.modules.d/00-mpm.conf

So go to the conf.modules.d directory, take a backup of current 00-mpm.conf file and then
Just uncomment this line

LoadModule mpm_worker_module modules/

And comment the below line

#LoadModule mpm_prefork_module modules/

Save the file.

Now you have changed the module from prefork to worker. But will this make PHP load?

You might be seeing this error or something similar when you try to restart Apache after configuring PHP with Prefork,

localhost.localdomain httpd[61702]: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the ser...guration
 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
 localhost.localdomain kill[61703]: kill: cannot find process ""
 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.

How to fix this?

Very simple, go to /etc/httpd/conf.d/ and rename php.conf file to something like php.conf_PREFORK. Now try restarting Apache. This should make apache start without any issues.

NOTE:- When you are using Apache Worker MPM, PHP can only run as a external CGI / FCGI process. There are lot of tutorials out there on how to run php as a CGI process hence I am not explaining that here.

Click to rate this tutorial!
[Total: 1 Average: 5]

Leave a Reply

Your email address will not be published.