在 Linux 上为 PHP 正确设置 ulimit

Jas*_*son 5 linux security centos ulimit

我已/etc/security/limits.conf设置为以下内容:

nobody soft nofile 409600
nobody hard nofile 1024000
phpuser soft nofile 409600
phpuser hard nofile 1024000
httpd soft nofile 409600
httpd hard nofile 1024000
* soft nofile 409600
* hard nofile 1024000
Run Code Online (Sandbox Code Playgroud)

但是,php页面仍然显示:

[...] failed to open stream: Too many open files [...]
Run Code Online (Sandbox Code Playgroud)

设置ulimit -n 10000看起来只是一个临时修复。

我也有以下设置:

fs.file-max = 20970800
net.core.somaxconn = 1024000
kern.maxfilesperproc = 16638400
kern.maxfiles = 819200
Run Code Online (Sandbox Code Playgroud)

gan*_*bra 0

您可以通过编辑limits.conf来永久设置ulimit。检查此链接

http://singztechmusings.wordpress.com/2011/07/11/ulimit-how-to-permanently-set-kernel-limits-in-linux/

如果是 php 文件,也请参阅此线程

/sf/ask/1115626081/