致命错误-打开的文件太多 [英] Fatal Error - Too many open files

查看:187
本文介绍了致命错误-打开的文件太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在新计算机上运行PHPUnit测试,但出现此错误:

I try to run PHPUnit Tests in my new machine and I get this error:

PHP致命错误:消息为'RecursiveDirectoryIterator :: __ construct(/usr/lib/php/pear/File/Iterator)的未捕获异常'UnexpectedValueException':无法在/usr/lib/中打开dir:打开文件太多php/pear/File/Iterator/Factory.php:114

PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(/usr/lib/php/pear/File/Iterator): failed to open dir: Too many open files' in /usr/lib/php/pear/File/Iterator/Factory.php:114

旧计算机上的相同代码运行良好...

The same code on the old machine run well...

新机器环境: PHP版本:PHP 5.3.21(cli) 旧版:PHP 5.3.14

New machine environment: PHP Version: PHP 5.3.21 (cli) Older: PHP 5.3.14

PHPUnit每次输出:

PHPUnit output every time:

................EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 65 / 66 ( 98%)
E

Time: 34 seconds, Memory: 438.50Mb

There were 50 errors:

1) XXXXXXXXXXX
PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(/usr/lib/php/pear/File/Iterator): failed to open dir: Too many open files' in /usr/lib/php/pear/File/Iterator/Factory.php:114

推荐答案

这可能是运行代码的服务器上的限制.每个操作系统仅允许一定数量的打开文件/句柄/套接字.在虚拟化服务器时,通常会进一步降低此限制.在Linux服务器上,您可以使用ulimit -n检查当前限制,如果您具有root用户访问权限,则可以使用相同的命令来增加它.我认为也有一种适用于Windows服务器的方法.否则,您无能为力(除非要求托管者或管理员增加它).

This can be a limitation on the server where the code is running. Every operating system only allows for a certain number of open files/handles/sockets. This limit is usually further reduced when the server is virtualized. On a Linux server you can check the current limit with ulimit -n, if you have root access you can increase it with the same command. I assume there is a method for Windows server as well. Otherwise there is not much you can do about it (except ask your hoster or administrator to increase it).

更多可配置的限制:

In /etc/security/limits.conf 
  soft nofile 1024 
  hard nofile 65535 
Increase ulimit by "ulimit -n 65535" 
echo 65535 > /proc/sys/fs/file-max 
In /etc/sysctl.conf 
  fs.file-max=65535 

这篇关于致命错误-打开的文件太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆