总结
豆包 AI 助手文章总结

nginx - php failed to open stream: Too many open files in

php中文网
发布: 2016-06-06 20:19:26
原创
2694人浏览过

Warning: require_once(/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php): failed to open stream: Too many open files in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136
PHP Fatal error:  require_once(): Failed opening required '/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php' (include_path='.:/usr/local/php/lib/php') in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136

Fatal error: require_once(): Failed opening required '/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php' (include_path='.:/usr/local/php/lib/php') in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136
登录后复制
登录后复制
// 从数据库取出一篇文章
include '../Requests-master/Request.php';
$article_cond='some cond';
$article=$db->fetchByCond($article_cond)
while($article)
{
    $return=Request::post($url,$data,$header);
    // do others
    $article=$db->fetchByCond($article_cond);
}
登录后复制
登录后复制

下面的是出错的这个文件

public static function autoloader($class) 
{
        // Check that the class starts with "Requests"
        if (strpos($class, 'Requests') !== 0) {
            return;
        }

        $file = str_replace('_', '/', $class);
        if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) {
            // 下面这行是136行
            require_once(dirname(__FILE__) . '/' . $file . '.php');
        }
    }
登录后复制
登录后复制

从数据库取出文章,然后用PHP Requests这个库将文章插入另一个服务器上的数据库(这里都是127.0.0.1)。不知道什么会出现这个问题,每插入1020篇文章就会出现这个问题,不知道是哪里设置的问题呢?

回复内容:

Warning: require_once(/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php): failed to open stream: Too many open files in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136
PHP Fatal error:  require_once(): Failed opening required '/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php' (include_path='.:/usr/local/php/lib/php') in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136

Fatal error: require_once(): Failed opening required '/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php' (include_path='.:/usr/local/php/lib/php') in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136
登录后复制
登录后复制
// 从数据库取出一篇文章
include '../Requests-master/Request.php';
$article_cond='some cond';
$article=$db->fetchByCond($article_cond)
while($article)
{
    $return=Request::post($url,$data,$header);
    // do others
    $article=$db->fetchByCond($article_cond);
}
登录后复制
登录后复制

下面的是出错的这个文件

public static function autoloader($class) 
{
        // Check that the class starts with "Requests"
        if (strpos($class, 'Requests') !== 0) {
            return;
        }

        $file = str_replace('_', '/', $class);
        if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) {
            // 下面这行是136行
            require_once(dirname(__FILE__) . '/' . $file . '.php');
        }
    }
登录后复制
登录后复制

从数据库取出文章,然后用PHP Requests这个库将文章插入另一个服务器上的数据库(这里都是127.0.0.1)。不知道什么会出现这个问题,每插入1020篇文章就会出现这个问题,不知道是哪里设置的问题呢?

Too many open files,这个提示说的很明白了,开发的文件太多了。

立即学习PHP免费学习笔记(深入)”;

一个进程打开的文件数目是有上限的,无法超过这个值,require_once是要打开文件的,所以就出错了。

回到你的问题,单纯require是不应该达到文件打开上限的,两个方向来查问题吧

  1. 是否存在循环require的问题?

  2. 是否在其他位置open文件太多并且没有close?

豆包AI编程
豆包AI编程

智能代码生成与优化,高效提升开发速度与质量!

下载
相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
豆包 AI 助手文章总结
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号