Linux – Apache crashing; “Too many open files in system”

apache-2.2centoslinux

I am running Apache2 with mpm_prefork on a MediaTemple (dv) server. No significant changes have been made to my server configuration recently. httpd.conf is currently set to the following:

MaxKeepAliveRequests 200
KeepAliveTimeout 15

<IfModule prefork.c>
    StartServers           10
    MinSpareServers        10
    MaxSpareServers        10
    MaxClients            200
    MaxRequestsPerChild   4000
</IfModule>

But I am getting the following error just prior to a full-on apache crash:

[Thu Jun 04 18:30:24 2009] [warn-phpd] mmap cache can't open /var/www/vhosts/mydomain.com/httpdocs/filename.php - Too many open files in system (pid 19873)

I am getting annoyed with babysitting this server to restart it when Apache crashes. Help?

Best Answer

I suggest you try adding a line like this ulimit -n 16384 to the top of file /etc/default/apache2 and then restarting.

Also see this link.