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

來源:互聯網
上載者:User
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 136PHP 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 136Fatal 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 136PHP 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 136Fatal 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,這個提示說的很明白了,開發的檔案太多了。

一個進程開啟的檔案數目是有上限的,無法超過這個值,require_once是要開啟檔案的,所以就出錯了。

回到你的問題,單純require是不應該達到檔案開啟上限的,兩個方向來查問題吧

  1. 是否存在迴圈require的問題?

  2. 是否在其他位置open檔案太多並且沒有close?

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.