Question
How-to capture core files from Apache?
Procedure
In some cases, Apache will stop unexpectedly because of a segmentation fault. To debug these types of problems, it's frequently advantageous to examine the "core dump" left by Apache when it ended.
Create the coredump directory:
# mkdir -vp /home/core_files
Note: Coredumps can be dumped to anywhere, however, it is recommended to not store these files in a user directory as they could have sensitive data.
Update the
core_patternkernel variable to use the coredump path:# echo '/home/core_files/%e.core.%t.%p' > /proc/sys/kernel/core_pattern
Note: The
%estarts the filename with the name of the executable that segfaulted,%tprints the time (in epoch), and %p adds the process id. An example would be:/home/core_files/httpd.core.1779530456.510214Enable full coredumps in the kernel:
# echo 2 > /proc/sys/fs/suid_dumpable
Enable coredump processing for cPanel:
# whmapi1 set_tweaksetting key='coredump' value=1
Add a
systemdconfiguration file override:# systemctl edit httpd
Add the following, and save the file:
CONFIG_TEXT: [Service]
LimitCORE=infinityNote: This will ensure that all relevant data is dumped to the file.
Reload
systemd:# systemctl daemon-reload
Restart Apache:
# /scripts/restartsrv_httpd
Now the server is ready to generate core dumps from Apache.
Warning: Please don't forget to turn these features off when you're done, as core dumps can contain sensitive data and can be very large.
To disable coredumps:
Disable coredumps in cPanel:
# whmapi1 set_tweaksetting key='coredump' value=0
Set the
suid_dumpablekernel configuration back to 0 (disabled).# echo 0 > /proc/sys/fs/suid_dumpable
Edit the
systemdconfiguration file override:# systemctl edit httpd
Remove the following line:
CONFIG_TEXT: LimitCORE=infinity
Reload
systemd:# systemctl daemon-reload
Restart Apache:
# /scripts/restartsrv_httpd
Comments
0 comments
Article is closed for comments.