LxRoot docs

Strace PHP

Stracing PHP can be a useful way to debug what a site or script is doing in order to track down the cause of a bug, hang or other problem. To begin with, you need to enter the same environment as the PHP processes.

                            su - [user]
                            

(where [user] is the username of the website you're switching to)

                            ps aux 
                            

Will show a list of processes running under that user. To attach an strace to a particular process, type

                                strace -p [process_id]
                                

This will then show the system calls that the PHP process is running, including connecting to a database or any external network requests. It will show if the process is hanging or if it's waiting around for something else to happen.