Check Apache Stack Limit
Luke Hebert
- 2 minutes read - 265 wordsApache worker processes inherit their stack size from the system’s ulimit settings, and a misconfigured limit can cause segfaults or unexpected crashes under load. The command below pulls the actual stack limit from the kernel’s per-process view, so you see exactly what the running httpd process is using rather than what a shell session reports.
The Command
grep stack /proc/$(ps -fu nobody | grep httpd | awk '{ print $3 }' | tail -n 1)/limitsWhat It Does
ps -fu nobodylists all processes owned by thenobodyuser (the typical Apache worker user).grep httpdfilters to the Apache daemon processes.awk '{ print $3 }'extracts the PID column.tail -n 1grabs the last PID (a representative worker).grep stack /proc/<PID>/limitsreads the kernel’s recorded resource limits for that process and prints the stack line.
Example Output
Max stack size 8192 8192 bytesThe three columns are the soft limit, the hard limit, and the unit. A value of 8192 means 8 KiB, which is the common default. If you see unlimited, the process has no stack cap.
When to Check This
- After a segfault or
SIGSEGVin a mod_php or mod_perl handler. - When comparing a production host against a staging host that behaves differently.
- Before raising
ulimit -sin an init script or systemd unit to confirm the change actually propagated to the worker.
Note
The /proc/<PID>/limits file reflects the limits as they were set at process start. Changing ulimit in a shell after Apache is already running will not affect existing workers. Restart Apache after any limit change.