Apache和打开文件

我已经尝试编辑/etc/security/limits.conf但是Apache需要一个PAM插件才能工作,对吧?

 nobody soft nofile 40960000 nobody hard nofile 102400000 phpuser soft nofile 40960000 phpuser hard nofile 102400000 httpd soft nofile 40960000 httpd hard nofile 102400000 nginx soft nofile 40960000 nginx hard nofile 102400000 * soft nofile 40960000 * hard nofile 102400000 

我试过设置

 fs.file-max = 20970800 net.core.somaxconn = 1024000 kern.maxfilesperproc = 16638400 kern.maxfiles = 819200 

在sysctl.conf中,但仍然没有运气。

我也在/etc/init.d/httpd设置了ULIMIT_MAX_FILES="ulimit -n 16384"

 ulimit -n xxxxxx 

这有效,但这只是暂时的。 安装nginx会解决这个问题还是有办法使这个工作?

错误是:

 [...] failed to open stream: Too many open files [...] 

如果你使用CentOS的默认httpd和configuration,Apache将以root用户身份启动(因此它可以绑定到80/443端口),将它们设置为root,注销并重新login,然后重新启动apache。