Symptoms
Apache web-server uses all free RAM and becomes unresponsive. The following error message appears in its error logfile:
-
on CentOS/RHEL-based distributions:
/var/log/httpd/error_log
-
on Debian/Ubuntu-based distributions:
/var/log/apache2/error.log
[mpm_prefork:error] [pid 12526] (12)Cannot allocate memory: AH00159: fork: Unable to fork new process
Cause
Too high values are set for the Apache MaxRequestWorkers
and ServerLimit
directives, due to which all RAM is being used by Apache and new processes cannot be spawned.
Resolution
Decrease the values of the MaxRequestWorkers
and ServerLimit
directives:
Note: The default value of MaxRequestWorkers
and ServerLimit
is 256.
-
Connect to the Plesk server via SSH.
-
Find which Multi-Processing Module (MPM) is currently in use:
# httpd -V | grep MPM
-
Open the file
/etc/httpd/conf.modules.d/01-cgi.conf
in any text editor (For example, vi editor) and decrease the values of the following directives:-
For MPM Event:
<IfModule mpm_event_module>
LoadModule cgid_module modules/mod_cgid.so
MaxRequestWorkers 256
ServerLimit 256
</IfModule> -
For MPM Prefork:
<IfModule mpm_prefork_module>
LoadModule cgi_module modules/mod_cgi.so
MaxRequestWorkers 256
ServerLimit 256
</IfModule>
-
-
Save the changes and close the file.
-
Restart the Apache service to apply the changes:
# service httpd restart
-
Connect to the Plesk server via SSH.
-
Find which Multi-Processing Module (MPM) is currently in use:
# apache2ctl -V | grep MPM
-
Change the MPM configuration:
-
For MPM Event:
Open the
/etc/apache2/mods-enabled/mpm_event.conf
in any text editor (For example, vi editor) and decrease the values of the following directives:MaxRequestWorkers 256
ServerLimit 256 -
For MPM Prefork:
Open the
/etc/apache2/mods-enabled/mpm_prefork.conf
file in any text editor (For example, vi editor) and decrease the values of the following directives:MaxRequestWorkers 256
ServerLimit 256
-
-
Save the changes and close the file.
-
Restart the Apache service to apply the changes:
# service apache2 restart