Linux – How to run a stack trace on Apache

apache-2.2centoslinuxPHP

I have a PHP web application running on Apache/mod_php that works fine for several days and then fails, returns 500 Internal Server Error.

I've turned on debug logging and do not see anything in the logs that points to a cause. The only way to fix the issue is to restart Apache.

I think I need to run a system trace to monitor the Apache process and force it fail using Apache bench or other load test tool. Problem is, I've never done this before so I'm not sure how I would go about it.

I am running CentOS 6.x. What tool would I use to run a system trace and how would I invoke it?

Best Answer

You can try strace

strace -f -p 22254 -s 80 -o /tmp/debug.lighttpd.txt

-p will be the PID of the apache process, this thread helps you finding it