To determine which MPM is currently configured, use the following command:
sudo httpd -V | grep -i mpm
The Prefork Module is ideal for single-threaded applications like PHP, which do not support multi-threading. It operates with a single parent process having multiple child processes, each handling one request at a time.
httpd.confEdit the /etc/httpd/conf/httpd.conf file to configure the Prefork Module. Below are the default values:
# File: /etc/httpd/conf/httpd.conf
<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
To calculate the optimal configuration for your Apache 2.4 setup, consider the memory and process requirements based on your server's specifications.
The provided data can be used as a reference for configuring Apache processes and memory allocation in line with your server's hardware capabilities.
On CentOS 9, the default MPM is the event module. To switch to Prefork, edit the /etc/httpd/conf.modules.d/00-mpm.conf file:
# File: /etc/httpd/conf.modules.d/00-mpm.conf
# LoadModule directives for different MPMs
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
#LoadModule mpm_worker_module modules/mod_mpm_worker.so
#LoadModule mpm_event_module modules/mod_mpm_event.so
Uncomment the line for the Prefork module and comment out others.
After updating the configurations, restart Apache to apply the changes:
sudo systemctl restart httpd