How can I see the number of maximum open files in PHP?

2.4k Views Asked by At

With PHP I'm running into failed to open stream: Too many open files errors, thru wp-cli as well as through fpm-php.

I've adapted things like fpm's rlimit and ulimit on the command line. Now it would be really nice if I can see the maximum number of files a script can open without running the (slow) code.

How can I see the number of file I can open, from PHP itself?

I know I can look at configuration files, but I want to see the actual number that the current script has available so that I can adapt configuration files and see which change actually makes sense.

Unfortunately phpinfo() doesn't show this number.

If there's a shell command that shows this number, this would be good enough of course, as I could just exec that.

1

There are 1 best solutions below

1
BhAvik Gajjar On

In php, before the execution, try this

exec('ulimit -S -n 2048');