简体   繁体   English

PHP / CentOS-无法打开流:打开的文件太多

[英]PHP / CentOS - failed to open stream: Too many open files

Its a little unclear as to if this is a PHP/Apache problem or a filesystem problem. 不清楚这是PHP / Apache问题还是文件系统问题。 I'm writing a script to check the referential integrity of our LDAP server so I'm pulling a lot of data. 我正在编写一个脚本来检查LDAP服务器的参照完整性,所以我提取了很多数据。 I'm using PHP 5.3.8, Apache 2.2.3, and CentOS 5.7(I think thats the right version) 我正在使用PHP 5.3.8,Apache 2.2.3和CentOS 5.7(我认为那是正确的版本)

When I run the script I get a PHP warning that says: 当我运行脚本时,我得到一个PHP警告,内容为:

Warning: include("fileName"): failed to open stream: Too many open files in "fileName" on line 50 Warning: include(): Failed opening '"fileName"' for inclusion (include_path='.:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear') in "fileName" on line 50 警告:include(“ fileName”):无法打开流:第50行的“ fileName”中打开的文件过多警告:include():无法打开包含的“ filename”(include_path ='。:/ usr / local / zend / share / ZendFramework / library:/ usr / local / zend / share / pear')在第50行的“ fileName”中

I've cut out a lot of code to include less files and it doesn't seem to make a difference. 我削减了很多代码以包含更少的文件,而且似乎没有什么不同。 I thought that it could possibly be because of how much data I was pulling(possibly due to thrashing) so I limited it and output the peak memory usage which was 7.5 MB (after I limited the return results) which is a decent chunk but not enough to kill the script. 我认为这可能是因为我提取了多少数据(可能是由于抖动),所以我限制了它并输出了7.5 MB的峰值内存使用量(在我限制了返回结果之后),这是一个不错的块,但不是足以杀死脚本。

In the midst of all of this, I googled the issue and found that it could be caused by a filesystem open file limit which could be changed by a command called ulimit. 在所有这些中,我搜索了这个问题,发现它可能是由文件系统打开文件限制引起的,该文件限制可以通过称为ulimit的命令进行更改。 The default is 1024. I set mine to 40000 for all users. 默认值为1024。我为所有用户将mine设置为40000。 Still didn't help. 仍然没有帮助。 My PHP script uses a total of 11 files after I stripped it down. 删除后,我的PHP脚本总共使用了11个文件。 I just don't understand why this is happening. 我只是不明白为什么会这样。

Any Ideas? 有任何想法吗?

Thanks in advance, 提前致谢,

Jordan 约旦

Did you modify the soft limit and the hard limit for that user ? 您是否为该用户修改了软​​限制和硬限制? Also, if this is an Apache process running under user say "apache_user", you will need to stop Apache, log off, log back in (make sure that both the soft/hard limits are in place) and startup the Apache process. 另外,如果这是一个在用户“ apache_user”下运行的Apache进程,则您将需要停止Apache,注销,重新登录(确保软/硬限制均已到位)并启动Apache进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM