简体   繁体   中英

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. I'm writing a script to check the referential integrity of our LDAP server so I'm pulling a lot of data. I'm using PHP 5.3.8, Apache 2.2.3, and CentOS 5.7(I think thats the right version)

When I run the script I get a PHP warning that says:

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

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.

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. The default is 1024. I set mine to 40000 for all users. Still didn't help. My PHP script uses a total of 11 files after I stripped it down. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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