nginx - php failed to open stream: Too many open files in
程序员文章站
2022-05-20 20:57:51
...
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,这个提示说的很明白了,开发的文件太多了。
一个进程打开的文件数目是有上限的,无法超过这个值,require_once是要打开文件的,所以就出错了。
回到你的问题,单纯require是不应该达到文件打开上限的,两个方向来查问题吧
是否存在循环require的问题?
是否在其他位置open文件太多并且没有close?
上一篇: 微信判定用户是否关注
推荐阅读
-
在Linux中打开了太多文件(Too many open files)的三种解决方法
-
php错误提示failed to open stream: HTTP request failed!的完美解决方法
-
CentOS Too Many Open Files 解决
-
Nginx failed Too many open files nginxulimit
-
java.net.SocketException: Too many open files
-
详解 Too many open files
-
详解 Too many open files
-
linux打开文件数 too many open files 解决办法
-
在Linux中打开了太多文件(Too many open files)的三种解决方法
-
如何解决Linux下Too many open files问题