I was enjoying the /etc/security/limits.d/ directory for splitting user configuration limits when something didn’t seem to work.
I added in limits.d/apache.conf the lines
root - nofile 65536
apache - nofile 8192
but the following still returned 1024
# service httpd restart
# grep files /proc/$(pidof httpd | cut -d\ -f1)/limits
1024
While I restarted httpd from the same bash process used to edit the limits.d – in which I had the following
# ulimit -n
1024
apache was ignoring the limits.d statement. This could have happened only if httpd was invoked without a `su` procedure (the one reading limits and setrlimit) – and that was actually the case on Red Hat 6.3.
So when the bash process fork-exec’d to httpd, the ulimit was still 1024 and no step were done to “raise” the limits; moreover after re-logging in and restarting httpd, the new limits were 65536 – the root’s one.
The solution on RHEL6.3 – for me – was to statically put apache ulimits in /etc/sysconfig/httpd.