沃梦达 / 编程问答 / php问题 / 正文

Apache PHP/OSX Mavericks:-无法打开流:打开的文件太多

Apache PHP/OSX Mavericks: - failed to open stream: Too many open files(Apache PHP/OSX Mavericks:-无法打开流:打开的文件太多)

本文介绍了Apache PHP/OSX Mavericks:-无法打开流:打开的文件太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到 OSX Mavericks,从那时起,我的开发机器上开始出现上述错误.代码中没有明显问题(它是一个自动生成的 Yii 示例应用程序).作为升级到小牛队的一部分发生的事情是:

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 从与 OSX Lion 捆绑的 5.2.x 升级到 5.4.x.
  2. 我必须通过安装 Zend Server 获得适用于 PHP 5.4 的 Zend 调试器,选择 ZendDebugger.so 并卸载 Zend Server(所有这些都是因为 Zend 没有为 php 5.4.x 提供独立版本的调试器).
  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, 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).

从那以后,我可能在加载和重新加载网站几次后遇到了这个问题.发生此错误后,我的 Web 服务器不断为本地主机上托管的任何其他应用程序返回相同的错误.我不得不提到静态网页的服务很好.

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.

我见过几个 threads 关于这个主题.大多数人指出代码中文件句柄未正确关闭的问题,从而超过了打开文件限制阈值.我还发现这个 thread 似乎表明这可能是Zend 调试器问题.还有一个 错误报告 为 php 5.2.x 提交.按照线程here,我尝试了以下内容:

I've seen several threads on this topic. Most point out to issues in code where file handles are not being closed properly, thereby crossing the open file limit threshold. I also found this thread which seems to suggest this might be a zend debugger issue. There's also a bug report filed for php 5.2.x. Following the thread here, I tried the following:

$ ulimit -a

哪个报告:

open files (-n) 256

还有,

sysctl -a | grep files

返回,

kern.maxfiles = 12288
kern.maxfilesperproc = 10240
kern.maxfiles: 12288
kern.maxfilesperproc: 10240
kern.num_files: 3248

另一个有趣的线程建议使用:

Another interesting thread suggests to raise this limit (currently 256) using:

ulimit -n 1024

我已经尝试了所有方法,但似乎没有任何效果.该问题也不能始终如一地重现.

I've tried everything, but nothing seems to be working. The problem is also not consistently reproducible.

我想知道使用 ulimit -n 1024 是否会影响 apache,因为据我所知,它会影响 shell 可以打开的文件数.

I am wondering is using ulimit -n 1024 is going to affect apache, since from what I've read, it affects the number of files shell can have open.

感谢任何帮助.

  1. 重新启动 apache 有一点帮助,直到再次遇到错误.
  2. 让网络服务器闲置一段时间(没有确定的时间间隔)也有帮助.
  1. Restarting apache helps for a bit, till the error is encountered again.
  2. Leaving the web server idle for a bit (no definite interval) also helps.

推荐答案

我可能正遭受信息过载的困扰.此处提供了一个可能的解释,我也在我原来的帖子.我想我错过了 OP 提到他在 Mac OSX 10.8.x 上工作的小细节.我在 10.9 上,所以我从页面下载了 zenddebugger.so,一切看起来都不错.一整天都没有得到一个太多打开的文件.

I was probably suffering from information overload. A possible explanation is offered here which I've also mentioned in my original post. I guess I missed the little detail where the OP mentions that he's working on Mac OSX 10.8.x. I'm on 10.9 so I downloaded the zenddebugger.so from the page and things are looking good. Haven't gotten a single too many open files all day.

所以,可能是 ZendDebugger 的问题.

So, perhaps it was a ZendDebugger issue.

这篇关于Apache PHP/OSX Mavericks:-无法打开流:打开的文件太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Apache PHP/OSX Mavericks:-无法打开流:打开的文件太多

基础教程推荐