Apache Osx Mavericks: - Failed To Open Stream: Too Many Open Files

I’ve recently upgraded to OSX Mavericks and since then, I’ve started getting the aforementioned error on my development machine. There is no obvious problem in the code (it’s an auto generated Yii sample application). What has happened as part of upgrade to Mavericks is:

  1. PHP was upgraded from 5.2.x which bundled with OSX Lion to 5.4.x.

  2. I had to get a Zend Debugger for PHP 5.4 by installing [Zend Server][2], picking up the ZendDebugger.so and uninstalling the Zend Server (all this because Zend doesn’t provide a standalone version of their debugger for php 5.4.x).

Ever since, I’m getting this problem after maybe loading and reloading the website a few time. After this error occurs, my web server keeps returning the same error for any other application hosted on localhost. I have to mention that static web pages are served up fine.

I found some references to the problem including suggestions like:

Increasing the max open files in shell using (defaults to 256):




ulimit -n 2048 



and:




    sysctl -a | grep files


returns:

    kern.maxfiles = 12288

    kern.maxfilesperproc = 10240

    kern.maxfiles: 12288

    kern.maxfilesperproc: 10240

    kern.num_files: 3248



So the limits seem fine to me. If anyone has seen this problem or is aware of the solution, I’d really appreciate some information.

I’m pretty sure you have already seen this, so just in case:

The guys from the internet set their limits to some crazy values like 1 000 000, I wonder if it’s really needed, but it probably worth giving a shot.

I found this thread - http://forums.zend.com/viewtopic.php?f=8&t=110823. Seems like it might have been a ZendDebugger bug which was causing more that 256 files (default is 256 in mac OSX 10) to be open. I’ve not seen the issue since I replaced zenddebugger.so with the newer version supplied in the thread.

Ok, this explains the issue.

Also don’t forget that ulimit only changes the resource limits for the current shell, so you’ll have to modify some files to make it work.

Yes, for sticky increase we can edit (or create) [font="Courier New"]/etc/launchd.conf[/font] and increase the limits. Add lines that look like the following (using values appropriate to your environment):




limit maxfiles 16384 32768



This above, will increase the soft limit to 16,384 and hard limit to 32,768 files.