# Too many open files, apache/php-cgi segfaults

## planet-admin

Did a search, but didn't find anything.

We're running Gentoo 2007.0, kernel 2.6.22, apache 2.0.58-r2, php 5.2.5 (with some patches for security).

We're seeing:

```
[Thu Mar 06 07:31:35 2008] [error] (24)Too many open files: mod_fcgid: couldn't set child process attributes: /var/run/fcgidsock/13118.12585

[Thu Mar 06 14:27:01 2008] [notice] mod_fcgid: process /home/forum/htdocs/index.php(12585) exit(communication error), get unexpected signal 11
```

in the apache logs, and this:

```
php-cgi[7255]: segfault at 0000000001cc5868 rip 0000000000672e4d rsp 00007fffc314b970 error 4

php-cgi[7428]: segfault at 0000000001ed7920 rip 0000000000672e4d rsp 00007fff970fd920 error 4

php-cgi[7496] general protection rip:673216 rsp:7fffe896f190 error:0

php-cgi[11680]: segfault at 0000000001f62818 rip 0000000000672e4d rsp 00007fff2aee7710 error 4

php-cgi[12585]: segfault at 0000000000000018 rip 0000000000673216 rsp 00007fff2cebe6e0 error 4

```

in dmesg.

If anyone has any ideas, they'd be much appreciated.

Thanks,

Michael

----------

## richard.scott

Do you have a need to run the php as a CGI?

----------

## planet-admin

 *richard.scott wrote:*   

> Do you have a need to run the php as a CGI?

 

The apache processes with mod_php each up so much RAM as opposed to mod_fcgid running php that the difference is half as many clients supported per server. (The servers are running minimum 8gb of RAM). There is a cluster of 4 servers running this particular website. Also, mod_fcgid removes the problems of some things being non-thread safe.

Michael

----------

## richard.scott

ah ok... fair enough   :Smile: 

Have you tried to increase the number of available file handles?

I think that's something to do with the ulimt command?

----------

## sf_alpha

looks in /etc/security/limits.conf ... Also config about max open file handle in apache

config soft as required and hard as x2 for soft for user apache

You should have at least 

MaxClients * 3 for server serving static files and php modules

MaxClients * 5 for server serving cgi or fastcgi based scripts

----------

