我尝试在我的新机器上运行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=65535
发布于 2018-06-03 04:22:32
如何设置文件打开限制(Linux或Max OS):
ulimit -n 10000
解决phpunit
或/和phpdbg
和Warning: Uncaught ErrorException: require([..file]): failed to open stream: Too many open files in [...]
的问题
发布于 2016-12-13 21:29:37
在php中,在执行之前,尝试以下代码
exec('ulimit -S -n 2048');
https://stackoverflow.com/questions/14748499
复制相似问题