我尝试在我的新机器上运行PHPUnit测试,得到以下错误:
PHP致命错误:未捕获异常‘'RecursiveDirectoryIterator::__construct(/usr/lib/php/pear/File/Iterator):’,消息为‘/usr/lib/php/pear/File/Iterator/Factory.php:114无法打开目录:打开的文件太多’in
同样的代码在旧机器上运行得很好。
新机器环境: PHP版本: PHP 5.3.21 (cli)旧版: PHP 5.3.14
每次的PHPUnit输出:
................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发布于 2013-02-07 18:39:33
在运行代码的服务器上,这可能是一个限制。每个操作系统只允许打开一定数量的文件/句柄/套接字。当服务器虚拟化时,此限制通常会进一步降低。在Linux服务器上,你可以用ulimit -n检查当前的限制,如果你有根访问权限,你可以用同样的命令增加它。我假设Windows服务器也有一种方法。否则,您对此无能为力(除非要求您的主机管理员或管理员增加它)。
更多可配置的限制:
/etc/security/limits.conf中的更改
soft nofile 1024
hard nofile 65535通过ulimit -n 65535、echo 65535 > /proc/sys/fs/file-max或/etc/sysctl.conf增加ulimit
fs.file-max=65535https://stackoverflow.com/questions/14748499
复制相似问题